Giter Club home page Giter Club logo

gradescope-autograder-template's Introduction

Gradescope Autograder Template

a good template for setting up gradescope autograding with python

  • uses github deploy key to make your gradescope tests always up to date with your assignment repo
  • makes it easy to test your solution locally with standard unittest
  • makes sure your solution files are deleted before testing on gradescope, therefore unaccessible to clever students trying import solution

TODO:

  • change to ED25519
  • block certain libraries (e.g. numpy) for assignments where they are prohibited
  • add default timeouts so students submissions don't do an infinite loop
  • add runner user to subvert those very clever students https://www.seas.upenn.edu/~hanbangw/blog/hack-gs/

setup

  1. use python 3+ (> 3.7 is best)
  2. install the requirements with pip install -r requirements.txt
  3. create and set up a deploy key (See "updating the assignment" for why we need deploy keys)
    1. follow instructions here to create a deploy key using RSA and without a passphrase. I recommend you make the deploy key read only and you save it locally at the location ~/.ssh/deploy_key
    2. Go into your github repo settings (settings with the gear icon -> deploy keys) and add the public key ~/.ssh/deploy_key.pub
    3. Copy over your private key ~/.ssh/deploy_key to gradescope_base/deploy_key. I recommend that you do not push this private key to your github repo so I've added it to the .gitignore
  4. In make_assignment.sh, change the value of GITHUB_REPO to the SSH git address of your repo ([email protected]/USERNAME/REPONAME.git) and the change the value of REPO_NAME to the name of your repo (e.g this one would be gradescope_autograder_template)

making a new assignment

  1. create a new folder with your assignment name $name
  2. in the assignment folder, create a solution template file (or folder) that students will have to complete (e.g. solution_template.py)
  3. in the assignment folder, create a completed solution file (or folder) $solution
  4. in the assignment folder, write unittest tests for the solution making sure that each file starts with test_

look at assignment0 for an example!

running your tests locally

you can run all your tests in the assignment folder with unittest

cd assignment0
python -m unittest *

upload the assignment on gradescope

  1. create the assignment zip with ./make_assignment.sh $name $solution
  2. upload the resulting $name.zip to gradescope

check assignment 0 for an example, it was created with ./make_assignment.sh assignment0 solution.py

updating the assignment

The regular way to update assignments is to upload each new version to the gradescope server, but this can be annoying. Instead, we can upload an assignment once and from then on have the newest version pulled from github every time the test is run.

So your code on gradescope needs to be able to pull your repo with the assignment tests. One way would be to make your repo public but this means your students could easily find the exact tests you're running! Another way would be to add your private ssh key to the code that runs the gradescope tests, but this means that anyone with that key can access all your other private repos! Instead we use a deploy_key that acts as a verification of your github account just for the purposes of pulling this specific repo. This means you can keep your repo private from your students, but the code on gradescope's servers will be able to pull any updates for this specific repo but for no other private repos of yours.

Once you set this up and upload an assignment for the first time, everything is done! You just need to push your changes to your repo and they will be pulled any time a test is run so your students always get the latest updates to your tests. No need to interact with gradescope, all changes you make to your repo will be pulled by gradescope before autograding

The only time you should need to re-run make_assignment.sh and reupload the assignment on gradescope is if you change the name of the assignment ($name) or the name of the solution ($solution)

gradescope-autograder-template's People

Contributors

mnoukhov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gradescope-autograder-template's Issues

deploy key in setup.sh

Here is your template setup.sh (see below). You state to make sure to include your private key at a specific location in this file. Exactly what does this mean? The private key should not be moved anywhere and should stay on a local computer. This seems like a security risk to me.

 Gordon
#!/usr/bin/env bash

# make_assignment.sh will replace the lines below, DO NOT REMOVE
[email protected]:fsu-sc/gradescope_template.git
REPO_NAME=gradescope-template

cd /autograder/source

apt-get install -y python3 python3-pip python3-dev

mkdir -p /root/.ssh
cp ssh_config /root/.ssh/config
# Make sure to include your private key here
cp deploy_key /root/.ssh/deploy_key
chmod 400 /root/.ssh/deploy_key
# To prevent host key verification errors at runtime
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

# Clone autograder files
git clone $GITHUB_REPO /autograder/$REPO_NAME
# Install python dependencies
pip3 install -r /autograder/$REPO_NAME/requirements.txt

Github repository not found

Hi,

I have followed your instructions closely (as far as I can tell). Here is my first question:
I am cloning my private repo (which is clone of sample-python-pytest-autograder). Should this repository be set for ssh access for https access? So far, I get failures in both modes. More specifically, when I upload the zip file to Gradescope, my output log file gives:

...
ollecting tomli>=1.0.0
  Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting iniconfig
  Downloading iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting exceptiongroup>=1.0.0rc8
  Downloading exceptiongroup-1.1.3-py3-none-any.whl (14 kB)
Installing collected packages: tomli, pluggy, packaging, iniconfig, exceptiongroup, pytest
Successfully installed exceptiongroup-1.1.3 iniconfig-2.0.0 packaging-23.2 pluggy-1.3.0 pytest-7.4.3 tomli-2.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
# github.com:22 SSH-2.0-babeld-542480ac
fatal: repository 'fsu-sc/PRIVATE-cs8-s18-labxx-gs.git' does not exist    <<<<<<< ERROR >>>>>>>
No apt-get.sh found in repo
No requirements.txt found in repo
No requirements3.txt found in repo
...

My private deploy key was stored in deploy_keys/ (public and private) via running the script ./make_deploy_keys.sh.
I would like to get verbose output so I can see the commands executed that generate the output in the output provide by the gradescope interface.

Here are the contents of ./git/config:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = https://github.com/fsu-sc/PRIVATE-cs8-s18-labxx-gs.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main

Therefore, I added the -x option to setup.sh, but that did not seem to affect the output provided by Gradescope.

The setup.sh command:

mkdir -p ${BASE_DIR}/${REPO_NAME}
git clone ${GIT_REPO} ${BASE_DIR}/${REPO_NAME}

is executed. GIT_REPO has the value:

GIT_REPO=fsu-sc/PRIVATE-cs8-s18-labxx-gs.git

and I am able to clone it manually via git clone $GIT_REPO.

My env.sh file is:

#!/bin/sh
GIT_REPO=fsu-sc/PRIVATE-cs8-s18-labxx-gs.git

and the file envVars.sh:

#!/usr/bin/env bash

# Extract just the git repo:
#   https://serverfault.com/questions/417241/extract-repository-name-from-github-url-in-bash

BASE_DIR=/autograder/git-repo
WITHOUT_SUFFIX="${GIT_REPO%.*}"
REPO_NAME="$(basename "${WITHOUT_SUFFIX}")"

echo \$BASE_DIR=$BASE_DIR
echo \$GIT_REPO=$GIT_REPO
echo \$REPO_NAME=$REPO_NAME

Somehow my repository is not set up properly from Gradescope's point of view. Ultimately, I need more detailed logs to help my debugging. Any help would be appreciated. Thanks.

Gordon

Unittest not found

I am following instructions in the README.md file, which states:

## running your tests locally
you can run all your tests in the assignment folder with `unittest`

cd assignment0
python -m unittest

You provide very detailed instructions, but the commands above don't work because unittest is not installed. In fact, it is not a part of the requirements file. Perhaps I am missing some instructions elsewhere? Of course, I know I can install `unittest`, but the idea is for me to follow your instructions since you want the system to work within Gradescope. I hope you are still listening. Thanks.
 
    Gordon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.