This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
GitHub classroom is great, and it lets educators create automatic grading solution with GitHub Actions. However, one of the pitfall is that students can easily change the unit test codes and GitHub actions workflow and educators cannot trust the automatic grading result. Another problem is that students must commit and push source code themselves. Educators therefore have no idea if students are copying from other or not. Also, educators don’t know how students develop their answer, and the details of every code change.
To solve the potential cheating problem and to move from passive to active learning, we need a source of truth to run unit test and keep all changes of source codes when students are writing codes.
First, we create .vscode/settings.json to enable auto save file with 3 seconds delay and 2 “run on save” add-on commands (one for Codespace and Visual Studio Code in Windows).
With this setup, every code change will save automatically and trigger auto_grader.py after saving the file.
Second, auto_grader.py runs specific unit test toward that the changed file.
If test fails, it overwrites autograding.json, commits code change with comment "[skip actions] " + sourceCodeFilePath, and push to GitHub Repo. Suffix comment with “skip actions” will suspend GitHub Actions to run for student grade, since it will keep commit and push to GitHub frequently else it will generate a lot of noise in GitHub Action.
If test passes, it sends a post request with header of student special API Key and body with source code file path and source code to Azure API management with Azure function API backend “pytester”. It checks the code corresponding test record from Azure table (TestResults), if pass previously, it returns "Repeated Successful Test.", else it runs unit test again in an isolated environment. If the unit test in Azure function pass as well, it overwrites autograding.json, commits code change with comment sourceCodeFilePath, push to GitHub Repo, then trigger GitHub Action for grading.
autograding.json defines how to grade students in GitHub Action. The guideline asks educators to set it one by one with web UI and it is hard to use for more than 100 tests! We have developed a script to generate this file and it can be overwritten into student repo!
How to identify student and protect unit test API?
We use Microsoft Azure API Management. CDK-TK creates user account and subscription for each student and setup rate limit. Here is the code snippet.
Azure function can extract student email from request header. Each student cannot call more than 10 times per minute.
How to run PyTest in Azure Function?
That is the hardest part! The problem is that you cannot modify and corrupt the Python code of the Azure Function. It means that you cannot let student submit code to overwrite or add into the executing Python runtime, which is not trusted, and Azure function is like a web application which has many concurrency PyTest need to run at the same time. Therefore, we need to create a separate process to run PyTest. The first trial is to install PyTest and related packages to the Azure Function runtimes and reuse the runtime. However, it cannot load packages if we make a code of source code and unit test in /tmp. Finally, we found that we can run commands to create a temporary Python Virtual Environment in /tmp, install package with pip, activate the virtual environment, extract standard unit test code, overwriten with student changed Python code and run an independent PyTest.
We are trying to speed up the process by saving the unit test virtual environment and Azure file share, then we can save time to create Virtual Environment and install packages every time execute the Azure Function.
How to work on your GitHub classroom Python Lab Exercises with Codespace?
How to work on your GitHub classroom Python Lab Exercises with VS Code in Windows?
Commit History can show how students derive their answer.
It is a step recorder and captures all code change every 3 seconds for each student. And it is possible to combine the code change and generate an animation gif. On the other hand, educators can detect student cheating based on the abnormally short commit history!
Azure table Test Results.
Educators can track each unit test completion time and understand the performance of your class.
Clone the repo
Update the student list
Deploy the project
It takes about an hour to complete as the creating Azure API management takes time.
Mail merge student_key.csv to your students with API Key.
Students need to set the API to config.py.
Visual Studio Code or GitHub CodeSpace
CodeSpace is great as students don’t need to install anything and be able to work on the lab exercises and assignment anywhere. However, GitHub classroom students can use CodeSpace without limit during the beta but after beta then it will be limited “The free allowance is estimated to be enough for a class of 50 with 5 assignments per month, on a 2 core machine with 1 codespace stored per student.”
Therefore, educators should prepare for downgrade to Visual Studio Code anytime. For my course, I request my students to use CodeSpace and Visual Studio Code alternatively. Firstly, it will be fine to downgrade anytime, and secondly, I can let my students experience both Windows and Linux development environment which is important for the future job!
Our settings convert the single point of assessment into the continuous change detection assessment, and educators can understand students real coding behavior. GitHub Classroom is suitable for students who are eager to learn and know how to use Git. For our case, learning Python programme is the first course for the first day of school, and it is hard to teach them use GitHub immediately. The push and grade are too passive and there is no workable solution to prevent students from changing GitHub Actions workflow and unit tests.
Our longer term goal is that GitHub Classroom auto grader will have a way to deny students changing the workflow and allows overwriting test codes before auto grading, this will allow us to get rid of running unit test in Azure Function.
Scalable solutions: API management, Azure Function in consumption plan, and Azure Storage Table are 100% server-less, so this solution is scalable, high availability, and cheap!
Thanks to the project collaborators include, Andy Lum, Jerry Lee, Fong Ho Luen, Jenny Cheung, Woodi Tsang, Eric Luan and Wina Yu from the IT114115 Higher Diploma in Cloud and Data Centre Administration.