commit cdba7de935ef81a804348f095ba112e0c6f6c3a7 Author: Zhenyu Qi Date: Sun Oct 5 03:47:45 2025 -0700 release 1.0.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..d07070f --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# zyBooksBot + +An intelligent automation bot for the zyBooks learning platform. Automatically complete Challenge Activities and Participation Activities with batch processing and real-time progress tracking. + +## Features + +- Smart automation for zyBooks Challenge and Participation Activities +- Batch processing for multiple chapters and sections +- Real-time progress tracking with detailed status +- Modern web interface with multi-select capabilities +- Stateless architecture supporting multiple users +- Robust error handling and recovery + +## Quick Start + +**Prerequisites:** Node.js (v14+) + +```bash +git clone https://git.qzydustin.com/qzydustin/zyBooksBot +cd zyBooksBot +npm install +npm start +``` + +Open http://localhost:3000 in your browser. + +## Usage + +1. Login with your zyBooks credentials +2. Select books and chapters +3. Use checkboxes for batch selection +4. Execute and monitor real-time progress + +## Technical Details + +**Stack:** Node.js, Express.js, JavaScript +**Communication:** HTTP API with Server-Sent Events +**Key Features:** Real-time streaming, frontend state management + +## Important Notes + +This tool is for educational purposes. Ensure compliance with your institution's academic integrity policies and zyBooks terms of service. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0bea771 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1350 @@ +{ + "name": "zyBooksBot", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "zyBooksBot", + "version": "1.0.0", + "dependencies": { + "axios": "^1.6.0", + "cors": "^2.8.5", + "crypto": "^1.0.1", + "express": "^4.18.2" + }, + "devDependencies": { + "nodemon": "^3.0.1" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", + "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.", + "license": "ISC" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", + "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1f7bdc1 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "zyBooksBot", + "version": "1.0.0", + "main": "server.js", + "scripts": { + "start": "node server.js", + "dev": "nodemon server.js" + }, + "keywords": [ + "zybooks", + "automation", + "education", + "challenge-activities", + "participation-activities", + "bot", + "batch-processing", + "student-tools" + ], + "dependencies": { + "express": "^4.18.2", + "axios": "^1.6.0", + "cors": "^2.8.5", + "crypto": "^1.0.1" + }, + "devDependencies": { + "nodemon": "^3.0.1" + } +} \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..d7760c6 --- /dev/null +++ b/public/index.html @@ -0,0 +1,86 @@ + + + + + + ZyBook Auto Solver + + + +
+
+

🚀 ZyBook Auto Solver

+

Automated ZyBook assignment completion tool

+
+ + +
+

Login to ZyBooks

+
+
+ + +
+
+ + +
+ +
+
+ + + + + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..0a026ba --- /dev/null +++ b/public/script.js @@ -0,0 +1,610 @@ +// Global variables +let authToken = ''; +let userId = ''; +let currentBook = null; +let currentChapter = null; +let userTimeSpent = 0; // Track user's cumulative time spent + +// ==================== UTILITY FUNCTIONS ==================== + +function showSection(sectionId) { + document.querySelectorAll('.section').forEach(section => { + section.classList.add('hidden'); + }); + document.getElementById(sectionId).classList.remove('hidden'); +} + +function showLoading(show = true) { + const loading = document.getElementById('loading'); + if (show) { + loading.classList.remove('hidden'); + } else { + loading.classList.add('hidden'); + } +} + +function addLogEntry(message, type = 'info') { + const log = document.getElementById('results-log'); + const entry = document.createElement('div'); + entry.className = `log-entry log-${type}`; + entry.textContent = `${new Date().toLocaleTimeString()} - ${message}`; + log.appendChild(entry); + log.scrollTop = log.scrollHeight; +} + +function updateProgress(current, total) { + const progressFill = document.getElementById('progress-fill'); + const progressText = document.getElementById('progress-text'); + const percentage = Math.round((current / total) * 100); + + progressFill.style.width = `${percentage}%`; + progressText.textContent = `Progress: ${current}/${total} (${percentage}%)`; +} + +// ==================== API FUNCTIONS ==================== + +// Get section parts count +async function getSectionPartsCount(section, chapter = currentChapter) { + try { + if (!section || !section.number) { + return 99; + } + if (!chapter || !chapter.number) { + return 99; + } + + const response = await fetch(`/api/section-parts/${currentBook.zybook_code}/${chapter.number}/${section.number}?auth_token=${authToken}`); + if (response.ok) { + const data = await response.json(); + if (data.success) { + return data.totalParts; + } + } + return 99; + } catch (error) { + console.error('Error getting section parts count:', error); + return 99; + } +} + +// Solve single section for batch processing +async function solveSectionForBatch(section, currentSection, totalSections, sectionIndex, globalPartTracker) { + try { + if (!currentBook || !currentBook.zybook_code) { + throw new Error('Current book not set'); + } + if (!currentChapter) { + throw new Error('Current chapter not set'); + } + if (!authToken) { + throw new Error('Auth token not set'); + } + if (!section) { + throw new Error('Section data missing'); + } + + const response = await fetch('/api/solve/section', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'text/event-stream' + }, + body: JSON.stringify({ + bookCode: currentBook.zybook_code, + chapter: currentChapter, + section: section, + auth: authToken, + timeSpent: userTimeSpent + }) + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const reader = response.body.getReader(); + const decoder = new TextDecoder(); + let buffer = ''; + let sectionResults = []; + + while (true) { + const { done, value } = await reader.read(); + if (done) break; + + buffer += decoder.decode(value, { stream: true }); + const lines = buffer.split('\n'); + buffer = lines.pop() || ''; + + for (const line of lines) { + if (line.startsWith('data: ')) { + try { + const data = JSON.parse(line.slice(6)); + + switch (data.type) { + case 'total': + addLogEntry(` 📊 [${sectionIndex}/${totalSections}] Section has ${data.total} parts`, 'info'); + break; + case 'progress': + addLogEntry(` ⚡ [${sectionIndex}/${totalSections}] Processing ${data.current}/${data.total}...`, 'info'); + break; + case 'result': + sectionResults.push(data); + globalPartTracker.completedParts++; + updateProgress(globalPartTracker.completedParts, globalPartTracker.totalParts); + const status = data.success ? '✅' : '❌'; + addLogEntry(` ${status} [${sectionIndex}/${totalSections}] Part ${data.part || sectionResults.length}: ${data.success ? 'Success' : 'Failed'} (Global: ${globalPartTracker.completedParts}/${globalPartTracker.totalParts})`, data.success ? 'success' : 'error'); + break; + case 'complete': + const successCount = sectionResults.filter(r => r.success).length; + addLogEntry(` 🎯 [${sectionIndex}/${totalSections}] Section completed! Success: ${successCount}/${sectionResults.length}`, 'success'); + break; + case 'error': + addLogEntry(` ❌ [${sectionIndex}/${totalSections}] Section failed: ${data.message}`, 'error'); + throw new Error(data.message); + } + } catch (e) { + if (e.message && e.message !== 'Unexpected end of JSON input') { + console.error('Error parsing SSE data:', e); + } + } + } + } + } + } catch (error) { + throw error; + } +} + +// Solve single section +async function solveSection(section) { + showSection('progress-section'); + + updateProgress(0, 1); + document.getElementById('results-log').innerHTML = ''; + addLogEntry(`Starting section: ${currentChapter.number}.${section.number} - ${section.title}`); + + try { + const response = await fetch('/api/solve/section', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'text/event-stream' + }, + body: JSON.stringify({ + bookCode: currentBook.zybook_code, + chapter: currentChapter, + section: section, + auth: authToken, + timeSpent: userTimeSpent + }) + }); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const reader = response.body.getReader(); + const decoder = new TextDecoder(); + let buffer = ''; + + while (true) { + const { done, value } = await reader.read(); + if (done) break; + + buffer += decoder.decode(value, { stream: true }); + const lines = buffer.split('\n'); + buffer = lines.pop() || ''; + + for (const line of lines) { + if (line.startsWith('data: ')) { + try { + const data = JSON.parse(line.slice(6)); + handleSSEMessage(data); + } catch (e) { + console.error('Error parsing SSE data:', e); + } + } + } + } + } catch (error) { + console.error('Section solving error:', error); + addLogEntry('Error solving section: ' + error.message, 'error'); + } +} + +// Handle SSE messages +function handleSSEMessage(data) { + switch (data.type) { + case 'start': + addLogEntry(data.message, 'info'); + break; + case 'total': + updateProgress(0, data.total); + break; + case 'progress': + updateProgress(data.current, data.total); + addLogEntry(data.message, 'info'); + break; + case 'result': + updateProgress(data.current, data.total); + const resultType = data.success ? 'success' : 'error'; + addLogEntry(data.message, resultType); + // Update user time spent if provided + if (data.timeSpent !== undefined) { + userTimeSpent = data.timeSpent; + } + break; + case 'complete': + addLogEntry(data.message, 'success'); + // Update final time spent if provided + if (data.finalTimeSpent !== undefined) { + userTimeSpent = data.finalTimeSpent; + } + break; + case 'error': + addLogEntry(data.message, 'error'); + break; + } +} + +function goHome() { + // Reset user time spent + userTimeSpent = 0; + + document.getElementById('results-log').innerHTML = ''; + document.getElementById('progress-fill').style.width = '0%'; + document.getElementById('progress-text').textContent = 'Ready to start...'; + + showSection('books-section'); +} + +// ==================== LOGIN & DATA LOADING ==================== + +document.addEventListener('DOMContentLoaded', function() { + const loading = document.getElementById('loading'); + if (loading) { + loading.classList.add('hidden'); + } + + const loginSection = document.getElementById('login-section'); + if (loginSection) { + loginSection.classList.remove('hidden'); + } +}); + +document.getElementById('login-form').addEventListener('submit', async (e) => { + e.preventDefault(); + + const email = document.getElementById('email').value; + const password = document.getElementById('password').value; + + showLoading(true); + + try { + const response = await fetch('/api/auth/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email, password }) + }); + + const data = await response.json(); + + if (data.success) { + authToken = data.auth_token; + userId = data.user_id; + loadBooks(); + } else { + alert('Login failed: ' + data.message); + } + } catch (error) { + console.error('Login error:', error); + alert('Login error: ' + error.message); + } finally { + showLoading(false); + } +}); + +async function loadBooks() { + showLoading(true); + + try { + const response = await fetch(`/api/books/${userId}?auth_token=${authToken}`); + const data = await response.json(); + + if (data.success) { + const booksList = document.getElementById('books-list'); + booksList.innerHTML = data.books.map(book => + `
+ ${book.title} + ${book.zybook_code} +
` + ).join(''); + + showSection('books-section'); + } else { + alert('Failed to load books: ' + data.message); + } + } catch (error) { + console.error('Error loading books:', error); + alert('Error loading books: ' + error.message); + } finally { + showLoading(false); + } +} + +async function loadChapters(bookCode, bookTitle) { + showLoading(true); + currentBook = { zybook_code: bookCode, title: bookTitle }; + + try { + const response = await fetch(`/api/chapters/${bookCode}?auth_token=${authToken}`); + const data = await response.json(); + + if (data.success) { + const chaptersList = document.getElementById('chapters-list'); + chaptersList.innerHTML = data.chapters.map((chapter, index) => + `
+ +
+ Chapter ${chapter.number}: ${chapter.title} + ${chapter.sections.length} sections +
+
+ +
+
` + ).join(''); + + window.chaptersData = data.chapters; + updateChapterSelectionCount(); + showSection('chapters-section'); + } else { + alert('Failed to load chapters: ' + data.message); + } + } catch (error) { + console.error('Error loading chapters:', error); + alert('Error loading chapters: ' + error.message); + } finally { + showLoading(false); + } +} + +function loadSections(chapter) { + currentChapter = chapter; + + const sectionsList = document.getElementById('sections-list'); + sectionsList.innerHTML = chapter.sections.map((section, index) => + `
+ +
+ Section ${chapter.number}.${section.number}: ${section.title} +
+
` + ).join(''); + + window.sectionsData = chapter.sections; + updateSectionSelectionCount(); + showSection('sections-section'); +} + +// ==================== CHAPTER MULTI-SELECT ==================== + +function updateChapterSelection() { + const checkboxes = document.querySelectorAll('#chapters-list input[type="checkbox"]'); + checkboxes.forEach((checkbox, index) => { + const listItem = checkbox.closest('.list-item-checkbox'); + if (checkbox.checked) { + listItem.classList.add('selected'); + } else { + listItem.classList.remove('selected'); + } + }); + updateChapterSelectionCount(); +} + +function updateChapterSelectionCount() { + const checkboxes = document.querySelectorAll('#chapters-list input[type="checkbox"]:checked'); + const count = checkboxes.length; + + const batchControls = document.querySelector('#chapters-section .batch-controls'); + let countDisplay = batchControls.querySelector('.selected-count'); + if (!countDisplay) { + countDisplay = document.createElement('div'); + countDisplay.className = 'selected-count'; + batchControls.appendChild(countDisplay); + } + countDisplay.textContent = `${count} chapters selected`; +} + +function selectAllChapters(selectAll) { + const checkboxes = document.querySelectorAll('#chapters-list input[type="checkbox"]'); + checkboxes.forEach(checkbox => { + checkbox.checked = selectAll; + }); + updateChapterSelection(); +} + +function selectSingleChapter(index) { + const chapter = window.chaptersData[index]; + currentChapter = chapter; + loadSections(chapter); +} + +async function executeSelectedChapters() { + const checkboxes = document.querySelectorAll('#chapters-list input[type="checkbox"]:checked'); + if (checkboxes.length === 0) { + alert('Please select at least one chapter'); + return; + } + + const selectedChapters = Array.from(checkboxes).map(checkbox => { + const parentDiv = checkbox.closest('.list-item-checkbox'); + const index = parseInt(parentDiv.dataset.chapterIndex); + return { + index: index, + chapter: window.chaptersData[index] + }; + }); + + const totalSections = selectedChapters.reduce((total, { chapter }) => total + chapter.sections.length, 0); + + showSection('progress-section'); + + updateProgress(0, 1); + document.getElementById('results-log').innerHTML = ''; + addLogEntry(`Starting batch processing of ${selectedChapters.length} chapters (${totalSections} sections total)`); + addLogEntry(`📊 Calculating total parts for all sections...`, 'info'); + + // Pre-calculate total parts + let totalParts = 0; + let sectionIndex = 0; + for (let i = 0; i < selectedChapters.length; i++) { + const { chapter } = selectedChapters[i]; + addLogEntry(`📚 Calculating chapter ${chapter.number}: ${chapter.title} (${chapter.sections.length} sections)`, 'info'); + + for (let j = 0; j < chapter.sections.length; j++) { + sectionIndex++; + const section = chapter.sections[j]; + addLogEntry(` 🔍 Getting parts count for section ${chapter.number}.${section.number}...`, 'info'); + const sectionParts = await getSectionPartsCount(section, chapter); + totalParts += sectionParts; + addLogEntry(` 📊 Section ${chapter.number}.${section.number} has ${sectionParts} parts`, 'info'); + } + } + + const globalPartTracker = { + totalParts: totalParts, + completedParts: 0 + }; + + updateProgress(0, totalParts); + addLogEntry(`🎯 Total parts to process: ${totalParts}`, 'success'); + + sectionIndex = 0; + + for (let i = 0; i < selectedChapters.length; i++) { + const { chapter } = selectedChapters[i]; + currentChapter = chapter; + addLogEntry(`📚 Starting chapter ${chapter.number}: ${chapter.title} (${chapter.sections.length} sections)`, 'info'); + + for (let j = 0; j < chapter.sections.length; j++) { + sectionIndex++; + const section = chapter.sections[j]; + addLogEntry(`📄 Starting section ${chapter.number}.${section.number}: ${section.title}`, 'info'); + + try { + await solveSectionForBatch(section, `${chapter.number}.${section.number}`, totalSections, sectionIndex, globalPartTracker); + addLogEntry(`✅ Section ${chapter.number}.${section.number} completed`, 'success'); + } catch (error) { + addLogEntry(`❌ Section ${chapter.number}.${section.number} failed: ${error.message}`, 'error'); + } + + await new Promise(resolve => setTimeout(resolve, 1000)); + } + + addLogEntry(`✅ Chapter ${chapter.number} completed (${chapter.sections.length} sections)`, 'success'); + + if (i < selectedChapters.length - 1) { + await new Promise(resolve => setTimeout(resolve, 2000)); + } + } + + addLogEntry(`🎉 Batch chapter processing completed! Processed ${totalParts} parts total`, 'success'); +} + +// ==================== SECTION MULTI-SELECT ==================== + +function updateSectionSelection() { + const checkboxes = document.querySelectorAll('#sections-list input[type="checkbox"]'); + checkboxes.forEach((checkbox, index) => { + const listItem = checkbox.closest('.list-item-checkbox'); + if (checkbox.checked) { + listItem.classList.add('selected'); + } else { + listItem.classList.remove('selected'); + } + }); + updateSectionSelectionCount(); +} + +function updateSectionSelectionCount() { + const checkboxes = document.querySelectorAll('#sections-list input[type="checkbox"]:checked'); + const count = checkboxes.length; + + const batchControls = document.querySelector('#sections-section .batch-controls'); + let countDisplay = batchControls.querySelector('.selected-count'); + if (!countDisplay) { + countDisplay = document.createElement('div'); + countDisplay.className = 'selected-count'; + batchControls.appendChild(countDisplay); + } + countDisplay.textContent = `${count} sections selected`; +} + +function selectAllSections(selectAll) { + const checkboxes = document.querySelectorAll('#sections-list input[type="checkbox"]'); + checkboxes.forEach(checkbox => { + checkbox.checked = selectAll; + }); + updateSectionSelection(); +} + +async function executeSelectedSections() { + const checkboxes = document.querySelectorAll('#sections-list input[type="checkbox"]:checked'); + if (checkboxes.length === 0) { + alert('Please select at least one section'); + return; + } + + const selectedSections = Array.from(checkboxes).map(checkbox => { + const parentDiv = checkbox.closest('.list-item-checkbox'); + const index = parseInt(parentDiv.dataset.sectionIndex); + return { + index: index, + section: window.sectionsData[index] + }; + }); + + showSection('progress-section'); + + updateProgress(0, 1); + document.getElementById('results-log').innerHTML = ''; + addLogEntry(`Starting batch processing of ${selectedSections.length} sections`); + addLogEntry(`📊 Calculating total parts for all sections...`, 'info'); + + // Pre-calculate total parts + let totalParts = 0; + for (let i = 0; i < selectedSections.length; i++) { + const { section } = selectedSections[i]; + addLogEntry(` 🔍 Getting parts count for section ${currentChapter.number}.${section.number}...`, 'info'); + const sectionParts = await getSectionPartsCount(section, currentChapter); + totalParts += sectionParts; + addLogEntry(` 📊 Section ${currentChapter.number}.${section.number} has ${sectionParts} parts`, 'info'); + } + + const globalPartTracker = { + totalParts: totalParts, + completedParts: 0 + }; + + updateProgress(0, totalParts); + addLogEntry(`🎯 Total parts to process: ${totalParts}`, 'success'); + + for (let i = 0; i < selectedSections.length; i++) { + const { section } = selectedSections[i]; + addLogEntry(`📄 Starting section ${currentChapter.number}.${section.number}: ${section.title}`, 'info'); + + try { + await solveSectionForBatch(section, i + 1, selectedSections.length, i + 1, globalPartTracker); + addLogEntry(`✅ Section ${currentChapter.number}.${section.number} completed`, 'success'); + } catch (error) { + addLogEntry(`❌ Section ${currentChapter.number}.${section.number} failed: ${error.message}`, 'error'); + } + + if (i < selectedSections.length - 1) { + await new Promise(resolve => setTimeout(resolve, 1000)); + } + } + + addLogEntry(`🎉 Batch section processing completed! Processed ${totalParts} parts total`, 'success'); +} \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..b94d36a --- /dev/null +++ b/public/style.css @@ -0,0 +1,399 @@ +/* Global Styles */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + min-height: 100vh; + color: #333; + overflow-x: hidden; + width: 100%; +} + +.container { + max-width: 900px; + margin: 0 auto; + padding: 20px; + width: 100%; + box-sizing: border-box; +} + +/* Header */ +header { + text-align: center; + margin-bottom: 30px; + color: white; +} + +header h1 { + font-size: 2.5rem; + margin-bottom: 10px; + text-shadow: 2px 2px 4px rgba(0,0,0,0.3); +} + +header p { + font-size: 1.1rem; + opacity: 0.9; +} + +/* Sections */ +.section { + background: rgba(255, 255, 255, 0.95); + backdrop-filter: blur(10px); + border-radius: 20px; + padding: 30px; + margin-bottom: 20px; + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); + border: 1px solid rgba(255, 255, 255, 0.2); +} + +.section.hidden { + display: none; +} + +.section h2 { + margin-bottom: 20px; + color: #4a5568; + font-size: 1.8rem; +} + +/* Forms */ +.form-group { + margin-bottom: 20px; +} + +.form-group label { + display: block; + margin-bottom: 8px; + font-weight: 600; + color: #4a5568; +} + +.form-group input { + width: 100%; + padding: 12px 16px; + border: 2px solid #e2e8f0; + border-radius: 10px; + font-size: 16px; + transition: border-color 0.3s ease; +} + +.form-group input:focus { + outline: none; + border-color: #667eea; + box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); +} + +/* Buttons */ +.btn { + padding: 12px 24px; + border: none; + border-radius: 10px; + font-size: 16px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + text-decoration: none; + display: inline-block; + text-align: center; +} + +.btn-primary { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; +} + +.btn-primary:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); +} + +.btn-secondary { + background: #f7fafc; + color: #4a5568; + border: 2px solid #e2e8f0; +} + +.btn-secondary:hover { + background: #edf2f7; + border-color: #cbd5e0; +} + +.btn-small { + padding: 8px 16px; + font-size: 14px; +} + +/* Back Button */ +.back-btn { + display: inline-block; + margin-bottom: 20px; + color: #667eea; + cursor: pointer; + font-weight: 600; + transition: color 0.3s ease; +} + +.back-btn:hover { + color: #5a67d8; +} + +/* List Containers */ +.list-container { + max-height: 400px; + overflow-y: auto; + border: 1px solid #e2e8f0; + border-radius: 10px; + padding: 10px; + overflow-x: hidden; + width: 100%; + box-sizing: border-box; +} + +.list-item { + padding: 15px; + border-bottom: 1px solid #f1f5f9; + cursor: pointer; + transition: background-color 0.2s ease; + word-wrap: break-word; + overflow-wrap: break-word; +} + +.list-item:hover { + background-color: #f8fafc; +} + +.list-item:last-child { + border-bottom: none; +} + +.list-item strong { + display: block; + color: #2d3748; + margin-bottom: 4px; +} + +.list-item small { + color: #718096; +} + +/* Checkbox List Items */ +.list-item-checkbox { + display: flex; + align-items: center; + padding: 15px; + border-bottom: 1px solid #f1f5f9; + transition: background-color 0.2s ease; + width: 100%; + box-sizing: border-box; + word-wrap: break-word; + overflow-wrap: break-word; +} + +.list-item-checkbox:hover { + background-color: #f8fafc; +} + +.list-item-checkbox.selected { + background-color: #ebf8ff; + border-color: #bee3f8; +} + +.list-item-checkbox:last-child { + border-bottom: none; +} + +.list-item-checkbox input[type="checkbox"] { + margin-right: 15px; + transform: scale(1.2); + flex-shrink: 0; +} + +.item-content { + flex: 1; + min-width: 0; +} + +.item-content strong { + display: block; + color: #2d3748; + margin-bottom: 4px; + word-wrap: break-word; + overflow-wrap: break-word; +} + +.item-content small { + color: #718096; +} + +.item-actions { + margin-left: 15px; + flex-shrink: 0; +} + +/* Batch Controls */ +.batch-controls { + margin-bottom: 20px; + padding: 15px; + background-color: #f7fafc; + border-radius: 10px; + border: 1px solid #e2e8f0; + display: flex; + gap: 10px; + flex-wrap: wrap; + align-items: center; +} + +.selected-count { + margin-left: auto; + font-weight: 600; + color: #4a5568; +} + +/* Progress Bar */ +.progress-bar { + width: 100%; + height: 20px; + background: #e2e8f0; + border-radius: 10px; + overflow: hidden; + margin-bottom: 15px; +} + +.progress-fill { + height: 100%; + background: linear-gradient(90deg, #48bb78, #38a169); + width: 0%; + transition: width 0.5s ease; +} + +#progress-text { + text-align: center; + font-weight: 600; + color: #4a5568; + margin-bottom: 20px; +} + +/* Results Log */ +.results-log { + max-height: 300px; + overflow-y: auto; + background: #f7fafc; + border: 1px solid #e2e8f0; + border-radius: 10px; + padding: 15px; + font-family: 'Monaco', 'Menlo', monospace; + font-size: 14px; +} + +.log-entry { + margin-bottom: 8px; + padding: 4px 0; +} + +.log-info { + color: #4a5568; +} + +.log-success { + color: #38a169; + font-weight: 600; +} + +.log-error { + color: #e53e3e; + font-weight: 600; +} + +/* Loading Animation */ +.loading { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.8); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + z-index: 1000; + color: white; +} + +.loading.hidden { + display: none !important; +} + +.spinner { + width: 50px; + height: 50px; + border: 4px solid rgba(255, 255, 255, 0.3); + border-top: 4px solid #fff; + border-radius: 50%; + animation: spin 1s linear infinite; + margin-bottom: 20px; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +.loading p { + font-size: 18px; + font-weight: 600; +} + +/* Responsive Design */ +@media (max-width: 600px) { + .container { + padding: 15px; + } + + header h1 { + font-size: 2rem; + } + + .section { + padding: 20px; + } + + .list-item-checkbox { + flex-direction: column; + align-items: flex-start; + gap: 10px; + } + + .item-actions { + margin-left: 0; + width: 100%; + } + + .item-actions .btn { + width: 100%; + } + + .batch-controls { + flex-direction: column; + align-items: stretch; + } + + .batch-controls .btn { + width: 100%; + margin-bottom: 10px; + } + + .batch-controls .btn:last-child { + margin-bottom: 0; + } + + .selected-count { + margin-left: 0; + text-align: center; + } +} \ No newline at end of file diff --git a/server.js b/server.js new file mode 100644 index 0000000..6fcc7d9 --- /dev/null +++ b/server.js @@ -0,0 +1,326 @@ +const express = require('express'); +const axios = require('axios'); +const cors = require('cors'); +const crypto = require('crypto'); + +const app = express(); +const PORT = 3000; + +// Configuration +const ZYBOOKS_CONFIG = { + BASE_URL: 'https://zyserver.zybooks.com/v1', + TIME_URL: 'https://zyserver2.zybooks.com/v1', + LEARN_URL: 'https://learn.zybooks.com', + HEADERS: { + 'Host': 'zyserver.zybooks.com', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0', + 'Accept': 'application/json, text/javascript, */*; q=0.01', + 'Accept-Language': 'en-US,en;q=0.5', + 'Content-Type': 'application/json', + 'Origin': 'https://learn.zybooks.com', + 'Referer': 'https://learn.zybooks.com/' + } +}; + +// Middleware +app.use(cors()); +app.use(express.json()); +app.use(express.static('public')); + +// Global error handlers +process.on('uncaughtException', (error) => { + console.error('Uncaught Exception:', error); +}); + +process.on('unhandledRejection', (reason, promise) => { + console.error('Unhandled Rejection at:', promise, 'reason:', reason); +}); + +// ==================== UTILITY FUNCTIONS ==================== + +function generateTimestamp(timeSpent = 0) { + const now = new Date(); + const future = new Date(now.getTime() + timeSpent * 1000); + const ms = String(Math.floor(Math.random() * 1000)).padStart(3, '0'); + return future.toISOString().replace(/\.\d{3}Z$/, `${ms}Z`); +} + +function generateChecksum(actId, timestamp, auth, part, buildkey) { + const data = `content_resource/${actId}/activity${timestamp}${auth}${actId}${part}true${buildkey}`; + return crypto.createHash('md5').update(data).digest('hex'); +} + +async function getBuildkey(axiosInstance) { + const response = await axiosInstance.get(ZYBOOKS_CONFIG.LEARN_URL); + const match = response.data.match(/zybooks-web\/config\/environment[^>]*content="([^"]*)/); + const decoded = decodeURIComponent(match[1]); + const config = JSON.parse(decoded); + return config.APP.BUILDKEY; +} + +async function calculateSectionParts(bookCode, chapterNumber, sectionNumber, authToken, axiosInstance) { + try { + const problemsResponse = await axiosInstance.get( + `${ZYBOOKS_CONFIG.BASE_URL}/zybook/${bookCode}/chapter/${chapterNumber}/section/${sectionNumber}?auth_token=${authToken}` + ); + + if (!problemsResponse.data || !problemsResponse.data.section) { + throw new Error('Invalid response: missing section data'); + } + + const problems = problemsResponse.data.section.content_resources; + if (!problems || !Array.isArray(problems)) { + throw new Error('Invalid response: missing or invalid content_resources'); + } + + const totalParts = problems.reduce((total, problem) => total + Math.max(problem.parts, 1), 0); + return { problems, totalParts }; + } catch (error) { + console.error('Error in calculateSectionParts:', error.message); + throw error; + } +} + +// Error response helper +function sendError(res, statusCode, message) { + console.error(`Error [${statusCode}]:`, message); + res.status(statusCode).json({ success: false, message }); +} + +// SSE message helpers +function sendSSEMessage(res, type, data) { + res.write(`data: ${JSON.stringify({ type, ...data })}\n\n`); +} + +// Core function to solve a single part +async function solvePart(actId, secId, auth, part, code, axiosInstance, timeSpent = 0) { + // Simulate time spent + const spentTime = Math.floor(Math.random() * 60) + 1; + const newTimeSpent = timeSpent + spentTime; + + // Send time record + await axiosInstance.post(`${ZYBOOKS_CONFIG.TIME_URL}/zybook/${code}/time_spent`, { + time_spent_records: [{ + canonical_section_id: secId, + content_resource_id: actId, + part: part, + time_spent: spentTime, + timestamp: generateTimestamp(newTimeSpent) + }], + auth_token: auth + }); + + // Get buildkey and generate checksum + const buildkey = await getBuildkey(axiosInstance); + const timestamp = generateTimestamp(newTimeSpent); + const checksum = generateChecksum(actId, timestamp, auth, part, buildkey); + + // Solve the problem + const response = await axiosInstance.post( + `${ZYBOOKS_CONFIG.BASE_URL}/content_resource/${actId}/activity`, + { + part: part, + complete: true, + metadata: "{}", + zybook_code: code, + auth_token: auth, + timestamp: timestamp, + __cs__: checksum + }, + { headers: ZYBOOKS_CONFIG.HEADERS } + ); + + return { success: response.data.success || false, timeSpent: newTimeSpent }; +} + +// ==================== API ROUTES ==================== + +// Login +app.post('/api/auth/login', async (req, res) => { + try { + const { email, password } = req.body; + if (!email || !password) { + return sendError(res, 400, 'Email and password are required'); + } + + const tempSession = axios.create(); + const response = await tempSession.post(`${ZYBOOKS_CONFIG.BASE_URL}/signin`, { email, password }); + + if (!response.data.success || !response.data.session) { + return sendError(res, 401, 'Invalid credentials'); + } + + res.json({ + success: true, + auth_token: response.data.session.auth_token, + user_id: response.data.session.user_id + }); + } catch (error) { + sendError(res, 500, 'Login failed - Server error'); + } +}); + +// Get books +app.get('/api/books/:userId', async (req, res) => { + try { + const { userId } = req.params; + const { auth_token } = req.query; + + if (!userId || !auth_token) { + return sendError(res, 400, 'User ID and auth token are required'); + } + + const axiosInstance = axios.create(); + const response = await axiosInstance.get( + `${ZYBOOKS_CONFIG.BASE_URL}/user/${userId}/items?items=%5B%22zybooks%22%5D&auth_token=${auth_token}` + ); + + const books = response.data.items.zybooks.filter(book => !book.autosubscribe); + res.json({ success: true, books }); + } catch (error) { + sendError(res, 500, 'Failed to get books'); + } +}); + +// Get chapters +app.get('/api/chapters/:bookCode', async (req, res) => { + try { + const { bookCode } = req.params; + const { auth_token } = req.query; + + if (!bookCode || !auth_token) { + return sendError(res, 400, 'Book code and auth token are required'); + } + + const axiosInstance = axios.create(); + const response = await axiosInstance.get( + `${ZYBOOKS_CONFIG.BASE_URL}/zybooks?zybooks=%5B%22${bookCode}%22%5D&auth_token=${auth_token}` + ); + + res.json({ success: true, chapters: response.data.zybooks[0].chapters }); + } catch (error) { + sendError(res, 500, 'Failed to get chapters'); + } +}); + +// Get section parts count +app.get('/api/section-parts/:bookCode/:chapterNumber/:sectionNumber', async (req, res) => { + try { + const { bookCode, chapterNumber, sectionNumber } = req.params; + const { auth_token } = req.query; + + if (!bookCode || !chapterNumber || !sectionNumber || !auth_token) { + return sendError(res, 400, 'Missing required parameters'); + } + + const axiosInstance = axios.create(); + const { totalParts } = await calculateSectionParts(bookCode, chapterNumber, sectionNumber, auth_token, axiosInstance); + + res.json({ success: true, totalParts }); + } catch (error) { + sendError(res, 500, 'Failed to get section parts'); + } +}); + +// Solve section with SSE +app.post('/api/solve/section', async (req, res) => { + // Set SSE headers + res.writeHead(200, { + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + 'Connection': 'keep-alive', + 'Access-Control-Allow-Origin': '*' + }); + + try { + const { bookCode, chapter, section, auth, timeSpent = 0 } = req.body; + + if (!bookCode || !chapter || !section || !auth) { + sendSSEMessage(res, 'error', { message: 'Missing required parameters' }); + return res.end(); + } + + console.log(`Solving section: ${chapter.number}.${section.number}`); + + const axiosInstance = axios.create(); + let currentTimeSpent = timeSpent; + + // Send start message + sendSSEMessage(res, 'start', { + message: `Starting section: ${chapter.number}.${section.number} - ${section.title}` + }); + + // Get problems and total parts + const { problems, totalParts } = await calculateSectionParts(bookCode, chapter.number, section.number, auth, axiosInstance); + sendSSEMessage(res, 'total', { total: totalParts }); + + let currentPart = 0; + let results = []; + + // Process each problem + for (let i = 0; i < problems.length; i++) { + const problem = problems[i]; + const parts = Math.max(problem.parts, 1); + + // Process each part + for (let partIndex = 0; partIndex < parts; partIndex++) { + currentPart++; + const partNum = partIndex + 1; + const actualPartIndex = problem.parts > 0 ? partIndex : 0; + + // Send progress + const progressMessage = parts > 1 + ? `Solving problem ${i + 1} part ${partNum}...` + : `Solving problem ${i + 1}...`; + sendSSEMessage(res, 'progress', { + current: currentPart, + total: totalParts, + message: progressMessage + }); + + // Solve the part + const result = await solvePart(problem.id, section.canonical_section_id, auth, actualPartIndex, bookCode, axiosInstance, currentTimeSpent); + currentTimeSpent = result.timeSpent; // Update time spent + + results.push({ problem: i + 1, part: partNum, success: result.success }); + + // Send result + sendSSEMessage(res, 'result', { + current: currentPart, + total: totalParts, + problem: i + 1, + part: partNum, + success: result.success, + timeSpent: currentTimeSpent, + message: result.success + ? `✅ Problem ${i + 1} part ${partNum} solved successfully` + : `❌ Problem ${i + 1} part ${partNum} failed` + }); + + console.log(`Problem ${i + 1}, Part ${partNum}: ${result.success ? 'Success' : 'Failed'}`); + await new Promise(resolve => setTimeout(resolve, 500)); + } + } + + // Send completion + const successCount = results.filter(r => r.success).length; + sendSSEMessage(res, 'complete', { + results, + successCount, + totalCount: results.length, + finalTimeSpent: currentTimeSpent, + message: `Completed! ${successCount}/${results.length} problems solved successfully` + }); + + res.end(); + } catch (error) { + console.error('Section solving error:', error.message); + sendSSEMessage(res, 'error', { message: `Error solving section: ${error.message}` }); + res.end(); + } +}); + +// Start server +app.listen(PORT, () => { + console.log(`🚀 ZyBook Auto Server running on http://localhost:${PORT}`); +});