Automate any online course with AI-powered quiz solving!
A smart Python script that handles course navigation and quiz completion on any e-learning platform using Playwright and Groq AI. Simply configure it once for your platform and let it do the work.
π Universal Platform Support - Works with any e-learning platform
π§ AI Quiz Solver - Handles multiple-choice, text, and coding questions
π€ Smart Navigation - Automates login, course access, and quiz flow
π Secure Setup - Credentials stored safely in .env files
π Detailed Logging - Track everything in quiz_automation.log
π οΈ Fully Customizable - Adapt to any platform or course structure
git clone https://github.com/ritikpandey01/Course-Automation
cd course-automation
pip install -r requirements.txt
playwright installCreate a .env file:
PLATFORM_EMAIL=[email protected]
PLATFORM_PASSWORD=your_password
GROQ_API_KEY=your_groq_api_keyEdit config.json to match your platform and course:
{
"platform": "YourPlatform",
"url": "https://yourplatform.com/login",
"course_name": "Your Course Name",
"course_frame": "",
"login": {
"email": {"role": "textbox", "name": "Email"},
"password": {"role": "textbox", "name": "Password"},
"button": {"role": "button", "name": "Sign In"}
},
"course_navigation": {
"role": "link",
"name": "Start Course"
},
"contents_navigation": {
"role": "button",
"name": "Contents"
},
"back_to_contents": {
"role": "link",
"name": "Back to Course"
},
"units": [
{
"name": "Module 1",
"subtopics": [
{"name": "Introduction", "quiz": "Quiz 1"},
{"name": "Basics", "quiz": "Quiz 2"}
]
}
],
"submit_buttons": [
{"role": "button", "name": "Submit"},
{"role": "button", "name": "Next"}
],
"next_buttons": [
{"role": "button", "name": "Next"},
{"role": "button", "name": "Continue"}
],
"quiz_prompt": "You are a helpful assistant. Answer this quiz question based on the provided context. Give only the answer, no explanations.",
"code_prompt": "You are a coding assistant. Write clean, working code to solve this programming problem. Only provide the code solution."
}python automate_platform.pyThe browser will open and automate your course. Check quiz_automation.log for progress!
Use browser dev tools (F12) to find the right selectors:
- Right-click on elements β Inspect
- Look for
roleandnameattributes - Use formats like:
{"role": "button", "name": "Submit"}
Every platform is different! Modify these sections in config.json:
- URLs: Update login and course URLs
- Selectors: Find platform-specific button/input selectors
- Course Structure: Map your actual units and subtopics
- Navigation Flow: Adjust navigation elements
- Prompts: Customize AI prompts for better answers
- β Multiple Choice - AI picks the best option
- β Text Questions - AI provides written answers
- β Coding Problems - AI writes complete code solutions
- π§ Others - Extend the script for drag-drop, file uploads, etc.
Want to handle drag-and-drop or other question types?
- Detect the question type in
solve_quiz()function:
if page.locator(".drag-drop-container").is_visible():
handle_drag_drop_question(page, config)- Create handler function:
def handle_drag_drop_question(page, config):
# Your custom logic here
pass- Add prompts to
config.json:
{
"drag_drop_prompt": "Instructions for drag-and-drop questions..."
}- Slow loading? Increase timeout values in the script
- Complex navigation? Add more selectors to config
- Special auth? Modify login logic in the main script
- Different layout? Adjust course structure mapping
Everything is logged in quiz_automation.log:
- Login success/failure
- Navigation steps
- Quiz questions and AI responses
- Error messages with details
- "Element not found" β Check selectors in browser dev tools
- Login fails β Verify credentials and check for CAPTCHAs
- Wrong answers β Improve AI prompts in config
- Timeouts β Increase wait times for slow platforms
Script runs with visible browser (headless=False) so you can:
- Watch the automation live
- See where it gets stuck
- Manually intervene if needed
- Answers depend on your prompts and page content
- Fine-tune
quiz_promptandcode_promptfor better results - Test with a few questions first
- Some platforms have anti-bot measures
- CAPTCHAs may require manual solving
- Rate limiting might slow things down
- Follow your platform's terms of service
- Use for learning, not cheating
- Understand the material, don't just complete it
Want to improve the script? Here's how:
- Fork the repo
- Create a feature branch:
git checkout -b cool-feature - Make your changes
- Commit:
git commit -m 'Add cool feature' - Push:
git push origin cool-feature - Open a Pull Request
Ideas for contributions:
- Support for more question types
- Better error handling
- Performance improvements
- Platform-specific templates
- GUI interface for easier setup
- More question type handlers
- Better AI prompt engineering
- Multi-course batch processing
- Progress analytics and reporting
Ready to automate your courses? π
Configure config.json for your platform, run the script, and watch the magic happen. Check the logs if anything goes wrong!