API for Classroom autograding?

I’m starting to use Github classroom autograding for a 300+ class. We’re using the autograding to do “mid-assignment checkpoints” – i.e. having students having to solve some part of the assigning in week 1 and finish the rest in week 2.

I’m hoping to use the “scores” features as that mid-assignment checkpoint. I can see that scores are being reported (see below)

…but I need an API to avoid having to scroll through 300+ students. I also would like to use an API to upload data to our LMS (Moodle) since an LTI mechanism isn’t available yet.

Is there an API for this? Would it just be better to drop back to non-classroom github actions and use the API’s to determine if those have succeeded?

Thanks for any pointers / guidance.

1 Like

Hi Dirk,

At this time, I don’t believe that there are any public APIs for GitHub classrooms of any kind. But you could look into using GitHub actions to send the point scores from each student’s submission on commit to an API provided by your Moodle instance. This could prevent you from having to tally up the scores manually.

You would have to write an action within your .github/workflows directory using the provided education/autograding action and making some HTTP requests using your own scripts.

Another teacher has recently created an action to tally up the test points and display them in a README.md badge on the assignment.

It seems possible that you could use the output from the education/autograding action as part of the body of the request to Moodle. You may also need to set up additional ENV variables within your action to reference whichever assignments in your Moodle instance to update the grade.

You can see an example project that uses the education/autograding action below.

Good luck!


As Dangeranger said, you can modify the GH action classroom.yml file. Add an id to the autograder step so that you can use its output in other steps. You can then probably just use curl to PUT the score somewhere. If you need to use an auth token for the PUT request, you can store that as a secret in the classroom organisation and access it as an environment variable in the action runner.

Something like this (curl command probably has errors ;)):

          # add id to step so outputs can be referenced
          - uses: education/autograding@v1
            id: autograder

          # put score somewhere
          - run: curl PUT "http://api/end-point" \
              -H "accept: application/json" -H "Authorization: ${{ secrets.authtoken }}"  \
              -H "Content-Type: application/json" \
              -d "{\"student username\":\"${{ github.actor }}\",\"repo\":\"${{ github.repository }}\",\"score\":\"${{ steps.autograder.outputs.Points }}\"}"

You can then do something on the other end of the PUT to filter scores for any student who hasn’t passed the week1 threshold.

You don’t have to use curl, and there might already be an action that you can use to send the data to somewhere you want, if you want to search the market place.

Variables you’ll probably need:
${{ github.actor }} - student’s github username
${{ github.repository }} - repository name (classroom-org/assignmentname-username)
${{ secrets.variable-name-set-for-secret }} - if you need to use an auth token, store it as a secret in the classroom org settings
${{ steps.autograder.outputs.Points }} - autograder score

That’s a good idea - thanks for sharing that. I’m assuming the ${{ secrets.variable-name-set-for-secret }} is templated early and not made available to the grading container as an environment variable there the student could pick it up? Does it appear in the logs?

Our challenge is that the github ID is not related to the LMS ID. Fortunately, Github classroom can provide a mapping for that so we will be able to get around it at some point.

For the moment, I’m stepping back from using the classroom autograding and just using actions. I’ve put together a short (~10 line) script that can then retrieve the actions completion status and time of the actions and we can then combine that with the github/LMS user ID map. This gets us what we want to know (“did the student get started on the 2 week assignment and get the checkpoint portion done on time”). I suspect I will run into the API limits for this for a class of 300 but I was going to cache the results if it comes to that (i.e. don’t need to check student again if they have completed what’s needed).

There’s more on using secrets in actions here: Encrypted secrets - GitHub Docs

I believe secrets are hidden *** on the action logs. It would be possible for students to edit the action though, and change data and endpoints being sent.

Yes tank you