Package: teachable-school-manager
Teachable School ManagerA complete suite to (automatically) manage your Teachable school like a pro.NoteThis project was forked frommaxbritto's projectwhich was itself forked frombuzkall's project(thanks guys!) because of major refactoring and added features which changes the goal of the original project.
Pull requests are accepted if you want to add new features/apis.DisclaimerThis project is unofficial and not supported by Teachable. It is published and made open source in order to help other teachers but it comes with no warranty whatsoever from the author or any contributor.Teachable.com doesn't have an official API to manage your school. It has some webhooks to trigger events and use them with services like Zapier, but there is no fast and practical solution to manage your school, especially for large student groups.
The website is done using Angular, and needs some api urls to load the content, so this project uses those api to collect data and perform actions as if you were using the web admin panel.This mean that if Teachable changes their APIs, scripts from this project could stop working and potentially do damage to your school data. At any time.
Please take that into consideration before using this project and don't come to me to ask for repairs afterwards ;)Install and ConfigInstall as standalone python packageThis script has been tested with python 3.9In case you wanted just the python package you can find it on PyPi, that's how to install:pip install teachable-school-managerAfter that you should copy the file that you find in/usr/local/etc/teachable/config_example.ini, rename it asconfig.iniand set your username, password and your teachable custom domain[DEFAULT]username=YOUR_TEACHABLE_USERNAMEpassword=YOUR_TEACHABLE_PASSWORDsite_url=https://YOUR_TEACHABLE_URLalongside all the other variables that you find thereDockerYou will find a Dockerfile in case you want to build yourself your own docker image.If you just want the pre-built app this is also available inDocker hub, you can pull it simply by:docker pull instezz/teachable-school-manager:latestCheck thedocker-compose.ymlto configure your server to use this application.ScriptsThe package will install scripts in/usr/local/bin/so you can just call them from cmdline.There is a single script calledteachableand by runningteachable -hyou will get all the commands that you can execute.Enroll users to a courseIf you want to enroll a whole list of users to a new course, you can do it withteachable enrollscript that receives a user list Excel or CSV file (you'll only need 2 columns:fullnameandemail) and a course id.usage: teachable enroll [-h] -i INPUT_FILE -c COURSEID [--dryrun]

Mass enroll users from Excel or CSV file into a specified course

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT_FILE, --input_file INPUT_FILE
                        Excel or CSV file. The only needed columns are 'fullname' and 'email'
  -c COURSEID, --courseId COURSEID
                        The id of the course they should be enrolled in
  --dryrun              Don't send the messages for real, just do a dry runIf your file is Userlist.xlsx and course id is 1234 you can enroll all the users in the file into this course by typing :teachable enroll -i path/to/file/Userlist.xlsx -c 1234If some of thoses users are already enrolled in the course, Teachable API currently ignores them.Unenrolling users from a courseIn case you wanted to unenroll a specific set of users from a course, you only have to prepare a file with their fullname and email and give it to theteachable unenrollscript and it will handle the rest.usage: teachable unenroll [-h] -i INPUT_FILE -c COURSEID [--dryrun]

Mass unenroll users from Excel or CSV file from a specified course.

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT_FILE, --input_file INPUT_FILE
                        Excel or CSV file. The only needed columns are 'fullname' and 'email'
  -c COURSEID, --courseId COURSEID
                        The id of the course they should be enrolled in
  --dryrun              Don't send the messages for real, just do a dry runAuto-unenrolling users that have been enrolled for too longIn case you wanted to unenroll everyone that has been enrolled to a course for a certain period of time (e.g. 365 days) there is a super cool script that handle that automaticall:teachable auto_unenroll.usage: teachable auto_unenroll [-h] -d DAYS [--dryrun]

Automatically unenroll all users that have been enrolled for a certain amount of days specified with -d option

optional arguments:
  -h, --help            show this help message and exit
  -d DAYS, --days DAYS  Specifies the number of days after which a user will be unenrolled. For instance -d 365 will unenroll every user that has been enrolled for 366 days or more. IMPORTANT: This action cannot be recovered. Use at your own risk.
  --dryrun              Don't send the messages for real, just do a dry runChanging user passwordIn case you wanted to change a user's password you can useteachable passsword -e user@email.comusage: teachable password [-h] -e EMAIL [-p PASSWORD]

Change password for the user. If password not set the system will generate a random one

optional arguments:
  -h, --help            show this help message and exit
  -e EMAIL, --email EMAIL
                        The email of the user that you want to change.
  -p PASSWORD, --password PASSWORD
                        The new password for the user [optional]The script will send automatically an email to the user with the new password so you don't have to do it (because Teachable could not implement that uh?).Quickly search users from the command lineIf you wanted to get info about some users and what courses they are enrolled in just useteachable usersscript:usage: teachable users [-h] -s SEARCH

Searches for users and returns a list

optional arguments:
  -h, --help            show this help message and exit
  -s SEARCH, --search SEARCH
                        What to search for (text contained in either email or user name)If no search is provided it will list ALL the users in the course, so pay attention ;)Quickly get a list of courses in your schoolIf you wanted to get a list of courses in your school just use theteachable coursesscript, pretty simple and sweet:usage: teachable courses [-h]

List courses in school

optional arguments:
  -h, --help  show this help message and exitGet User ReportsUseteachable user_report. Typing --help will show the parameters infousage: teachable user_report [-h] [--emails EMAILS [EMAILS ...] | --search [SEARCH]] [--format [FORMAT]] [--courseid [COURSEID]] [--output_file [OUTPUT_FILE]] [--detailed]

Get your Teachable students report. By default, if no --emails or --search options are provided it will generate a progress summary report of all the students that are enrolled in all your courses. This is very similar to using teachable leaderboard: while this allows to specify a specific set of users, the
other one allows to specify a course.Pay attention if you have a lot of students because this will be rate limited at some point.

optional arguments:
  -h, --help            show this help message and exit
  --emails EMAILS [EMAILS ...], -e EMAILS [EMAILS ...]
                        list of emails (separated by spaces)
  --search [SEARCH], -s [SEARCH]
                        Searches specific text in name or email. For instance -s @gmail.com or -s *@gmail.com will look for all the users that have an email ending in @gmail.com. Or -s Jack will look for all the users that have Jack in their name (or surname)
  --format [FORMAT], -f [FORMAT]
                        Output format (excel, csv, txt [default])
  --courseid [COURSEID], -c [COURSEID]
                        Limit search to this course id only (numeric value)
  --output_file [OUTPUT_FILE], -o [OUTPUT_FILE]
                        Output file
  --detailed, -d        Get detailed progress reportBy default it will generate a progress summary report on screen of all the students that are enrolled in all your courses.If you add a specific email it will generate the student summary for the specific email or emails on screen.teachable user_report -e STUDENT_EMAIL
teachable user_report -e STUDENT_EMAIL1 STUDENT_EMAIL2Specifying the output file won't output anything to the screen and will save it into a file:teachable user_report -e STUDENT_EMAIL -o FILENAME.txtYou also can choose to export as a csv file (comma separated values):teachable user_report -e STUDENT_EMAIL -o FILENAME.csv -f csvIf you want a detailed report of the activity of a student or all the students just use the -d flag. For instance:teachable user_report -e STUDENT_EMAIL -o FILENAME.csv -f csvIf you want to do a lazy search of all the students with a specific name or email you can use the flag -s (which can't be used with the flag -e). For instance if you want to search for all the users with a @gmail.com address or named Martin:teachable user_report -s @gmail.com -o FILENAME.csv -f csv -d
teachable user_report -s Martin -o FILENAME.csv -f csv -dGet Leaderboard directly from Teachable siteWith the scriptteachable leaderboardyou can get the Leaderboard, i.e. the Summary of the progress report for all the students enrolled in a specific course with just one API call.Calling teachable leaderboard --help will show:usage: teachable leaderboard [-h] [--search [SEARCH]]

Get a Leaderboard CSV in just one command. It will save as many leaderboards CSV as you have courses.

optional arguments:
  -h, --help            show this help message and exit
  --search [SEARCH], -s [SEARCH]
                        Searches specific text in the name of the courseBy default this will generate leaderboards for all the courses in your school. If you want to generate the leaderboard for a specific course you can useteachable leaderboard -s PART_OF_THE_NAME_OF_YOUR_COURSERemind people to take a courseThis is taken care of by theteachable remindscript:usage: teachable remind [-h] [--reportonly | --notifyonly] [--dryrun]

Polls Teachable and sends reminders to those that haven't started a course or haven't done a lesson in a week.

optional arguments:
  -h, --help        show this help message and exit
  --reportonly, -r  Send the weekly report, not the notifications to all the users
  --notifyonly, -n  Send the notifications to the users not the weekly report
  --dryrun, -d      Don't send the messages for real, just do a dry runThere's a host of variables that you will find inconfig_example.inithat will help you send automatic reminders to people that are enrolled but are inactive (and have not done 100% of the course).The first part deals with sending emails:# the username you use to login to your emailserversmtp_user=name.surname@email.com# the password you use to login to your emailserversmtp_pwd=asfagrbsfva# your emailserversmtp_server=smtp.email.com# emailserver portsmtp_port=587# The from friendly name you will use in your emailssmtp_from='Your Friendly User (Company)'Then there is a section dedicated to configure some parameters that help you decide who will receive notifications# the frequency of the reminders (days) you will config belowfreq=7# the amount of days of inactivity you want to give a user before sending a# reminderalert_days=7# The amount of days that we wait before flagging to the contact person that# a user is not working enoughwarning=21And finally you can add as many sections as you want for as many companies you are serving through with your course. This can also be configured to send emails to everyone but pay attention, if you have plenty of users it's going to be expensive.[ACMEINC]# the frequency of the reminders (days), in case different than the default# freq = 7# what domain to search for the users of the specific company have in Teachableemailsearch=@acme.com# the contact person email you are going to send company reports tocontact_email=name.surname@acme.com# the contact person name you are going to send company reports tocontact_name=Friendly Contact# The course IDs these users are signed up to, comma separated# course_id = 123513, 1243151, 235345, ...course_id=134135Once you have configured all of this you only have to fire the right script (first run with--dryrunto see what happens)teachable remind --dryrun
# and then if all goes well...
teachable remindYou will find logs for all of this in/usr/local/var/log/teachable.logIf you are using the Docker image this script will run every week (or whenever you configure in thescheduler.inifile) via theteachable scheduler.Get your earning statements (and email them to you)You can regularly poll Teachable to get your earning statements as an Excel (default) or CSV file using theteachable statementsscript.By using the--emailoption the statements will be automatically sent to your email address (the one you use for sending the email that you have configured inconfig.ini)usage: teachable statements [-h] [--email] [--all] [--format [FORMAT]] [--ofile [OFILE]]

Get the latest earning statement as Excel (default) or CSV. Optionally send them over email to the school owner

optional arguments:
  -h, --help            show this help message and exit
  --email, -e           Send the statements to the school owner
  --all, -a             Get all the statements, not just the last one
  --format [FORMAT], -f [FORMAT]
                        Output format (excel[default], csv)
  --ofile [OFILE], -o [OFILE]
                        Output file nameIf you are using the Docker image this script will run every week (or whenever you configure in thescheduler.inifile) via theteachable_scheduler.SchedulerIf you are like me you want to automate as much as possible your school management and put things on auto-pilot (which is the whole reason why I have built this suite of management scripts ;) ).That's why we haveteachable schedulerwhich gets configured by setting up thescheduler.iniconfig file (there is an example no worries), for instance you can runecho testevery minute just by setting the following config section in that file:[dumb_echo]# Name of the script to callscript=echo# options to the scriptopts=test# how often it should runevery=1# when to schedule the task (you can put here a day like saturday, sunday, ... or# you can put here weeks . Check schedule docs for all possible syntaxwhen=minute# at what timeat_when=The scheduler will reload automatically every time you re-configure thescheduler.iniconfig file, so you don't have to restart every time the container for a simple configuration change.Cache and rate limitsTo avoid reaching any rate limit, the script caches the courses' data into a file usingshelve. This file caching mechanism does not support concurrent reading/writing; because of this if you try to run 2 instances of the API the second one will wait until the first one is done and released the cache files.The default cache file expiration is set to 3 days in theconfig_example.ini, but you can configure that how you want.DebuggingRemember: this is still in active development and in beta so there will be some debugging to do every once in a while. Everything gets logged in the logfile that you find at/usr/local/teachable/log/in the Docker container. I hope things are clear in there and will help you.That's it, enjoy ;)Stefano