This Node.js project automates solving Moodle quizzes by using Puppeteer to interact with the Moodle web interface and Google's Gemini AI to fetch the correct answers.
- 🚀 Automates Moodle quiz solving using Puppeteer
- 🤖 Leverages Gemini API to get AI-generated answers
- 📦 Simple Express server to trigger the solving process via API
- 🔐 Environment variables for secure configuration
project/
├── app.js # Main server & logic
├── .env # Environment variables
├── package.json # Project metadata and dependencies
├── node_modules/ # Installed dependencies
git clone https://github.com/tedddby/MoodleQuizSolver.git
cd MoodleQuizSolver
npm install
Create a .env
file in the root directory with the following variables:
GEMINI_API=your_gemini_api_key
Set your credentials and quiz id in app.js
MOODLE_USERNAME=your_moodle_username
MOODLE_PASSWORD=your_moodle_password
QUIZ_ID=quiz_id
Start the server:
npm start (configured nodemon command)
Then trigger the solving process by sending a request to your endpoint (e.g., /start
).
⚠️ Make sure you’ve set the correct quiz ID and login credentials in yourapp.js
and a valid Gemini api key in your.env
.
- Puppeteer logs into Moodle using the credentials.
- It navigates to the quiz and reads each question and its options.
- For each question, the app sends a prompt to Gemini API.
- The AI responds with the most likely correct option.
- Puppeteer selects the answer and moves to the next.
- Store your API key only in
.env
. - Do not commit
.env
or any sensitive data to version control.
This project is licensed under the MIT License. Feel free to use and modify it as needed.
Feel free to fork and submit pull requests if you'd like to improve this project!