<p>I have seen universities use linters and test suites to automatically check the correct state of the assignment so it can be submitted. Here is an example in <a href="http://www.krivers.net/15112-f17/notes/cs112_f17_linter.py" rel="nofollow noreferrer">Python</a> or the student assignment <a href="http://csapp.cs.cmu.edu/3e/datalab-handout.tar" rel="nofollow noreferrer">helper programs</a> in C, used for the book CS:App as another example of possible small programs you could include with assignments to make this easier to review submissions.</p>

CC BY-SA 4.0
2019-06-09T18:16:10.440Z
2019-06-09T18:16:10.440Z
JJbh
<p>I used <a href="https://stepik.org" rel="nofollow noreferrer">stepik.org</a> for my functional programming lab (in Java). It works like a charm.
As for me, the only missing part is plagiarism detection. I believe you should it give it a go!</p>

<p>With stepik, you have the features of a basic LMS (learning management system). Basically you can publish an online course (with several chapters..); you can get "students" to join the course, publish assignments; if needed define time window to submit assignments. </p>

<p>Among assignments (quizzes, Fill in the blanks, ...), it is possible to set up code assignments. For the code assignment, most of popular programming languages are possible (including Java, Python, C/C++, SQL, ...). </p>

<p>In order to assess an assignment, you need to define a test case. Typically, inputs are read from the console (for instance using <code>new Scanner(System.in).nextLine()</code> in Java), then the student's solution output needs to match the expected output defined for the test case.</p>

<p>More details can be found in <a href="https://support.stepik.org/hc/en-us/articles/360000159673-Types-of-assignments" rel="nofollow noreferrer">stepik assignement types</a></p>

CC BY-SA 4.0
2019-02-14T19:56:02.380Z
2019-02-21T13:05:24.603Z
2019-02-21T13:05:24.603Z
Abdu
<p>My development team (Mrs Marsupial) implemented an application and later a server (because COVID necessitated more remote learning) that solves a lot of these difficulties.  The student uploads their code and the server compiles and runs their code (fairly securely using docker) and the uses LaTeX to generate a .PDF file containing (i) their code suitably formatted and with the files in the correct order; (ii) any compile messages; (iii) the output of their program and (iv) any messages sent to stderr by their program.  Most of the time, if the program works correctly you can just get on with marking the program and adding feedback (I use an ipad to annotate the pdf directly, more time consuming than annotating paper, but still reasonable).  For each module there is am XML file of metadata specifying what files are needed, which data files should be downloaded for testing the program and output files that should be included in the .PDF.</p>
<p>If the program doesn't work, the .pdf file contains an embedded .zip file containing the code (in a consistent format) so the marker can extract the code and investigate the problem.</p>
<p>This has reduced marking time very substantially and the students seem to like it as well as they can see exactly what the marker sees (no more &quot;it works on my computer&quot;) and also the server keeps a reliably time-stamped record of what was uploaded in case of problems later and the students are encouraged to make regular provisional submissions (no more &quot;my hard drive failed&quot; etc.)</p>
<p>We are looking to add extra features such as plagiarism detection and more automated code analysis.  However, a lot of programming is not whether the computer understands the code, but whether a human reader does, so there are some aspects of programming that simply cannot be marked automatically (and when computers can do that, we probably won't need programmers anymore ;o)</p>
<p>P.S. I use a simple BASH script to email the feedback to the students, which is much easier than messing around with BlackBoard etc.</p>

CC BY-SA 4.0
2022-05-12T11:32:11.857Z
I like this answer, though it sounds like a gargantuan effort to set up!
Ben I.
CC BY-SA 4.0
2022-05-12T11:36:28.663Z
We developed it over a number of years, so it wasn't too bad (and was offset in the reduction in the amount of time I spend marking).  The biggest step was implementing it as a reasonably secure server, but that turned out to provide the greatest benefit.  I am very fortunate in having made a good choice of Mrs Marsupial (she is a much more productive programmer than I am ;o)
Dikran Marsupial
CC BY-SA 4.0
2022-05-12T10:12:49.863Z
2022-05-12T10:12:49.863Z
Dikran Marsupial
<p>Some interesting projects for those working with block-based languages (such as Scratch, Snap! and Blockly):</p>

<p>For Scratch, check out <a href="http://www.drscratch.org/" rel="nofollow noreferrer">Dr Scratch</a>, which takes a rubric approach to evaluating how much 'computational thinking' is evidenced by a project. Whilst the analysis might seem a bit reductive, it can be used independently by learners and includes some useful guidance on how to progress. The developers describe their approach in <a href="http://www.um.es/ead/red/46/moreno_robles.pdf" rel="nofollow noreferrer">this paper</a>. Dr Scratch is built on <a href="https://github.com/ucsb-cs-education/hairball" rel="nofollow noreferrer">Hairball</a>, a Python module which does static analysis of Scratch projects. </p>

<p>A more conventional autograder, <a href="https://github.com/cycomachead/lambda-evaluator" rel="nofollow noreferrer">lambda</a>, is being developed by Michael Ball for Snap! It's already integrated into UCB's <a href="http://bjc.berkeley.edu/" rel="nofollow noreferrer">Beauty and Joy of Computing</a> MOOC, and I think there are plans to make this more widely available. Michael wrote about this for <a href="https://s3-eu-west-1.amazonaws.com/rpi-magazines/issues/full_pdfs/000/000/004/original/HelloWorld03.pdf#page=26" rel="nofollow noreferrer">Hello World #3</a>.</p>

<p>Chris Roffey has developed an autograder for Blockly used in the initial round of the <a href="https://challenge.tcsocc.uk/index.php?action=user_competitions" rel="nofollow noreferrer">TCS Oxford Computing Challenge</a> programming challenge, although I don't think the code for this is shared publicly.</p>

CC BY-SA 3.0
2017-10-21T08:21:42.643Z
2017-10-21T08:21:42.643Z
Miles
<blockquote>
  <p>As a TA, the usual workflow for grading programming assignments for an
  introductory course would be:</p>
  
  <ol>
  <li>Some instructors used email as a submission mechanism (yes, really.)</li>
  </ol>
</blockquote>

<p>"<em>Yes, really</em>"? In the introductory course at my university we submitted our programs as printouts.</p>

<blockquote>
  <p>If you take C++ code that runs on Windows, it may not necessarily run on MacOS if it has platform dependent code. Introductory students make these mistakes all the time.</p>
</blockquote>

<p>It seems to me that the mistake is using C++ for an introductory course. Complete beginners do not need help shooting themselves in the foot. The curriculum may be out of your control, but if you have the option then teaching the introductory course either in a strongly typed LISP (SML, Haskell, or something similar) or at least in a concise portable language (Python, Ruby, etc.) should make it easier for both the students and the graders.</p>

CC BY-SA 3.0
2017-10-23T07:49:47.880Z
2017-10-23T07:49:47.880Z
Peter Taylor
<p>Please, take a look at <a href="http://stepik.org" rel="nofollow noreferrer">Stepik</a>. Actually I myself work at Stepik, but if you're looking for a free cloud-based solution, it might be really useful for you. Code challenges are tested using stdin->stdout and you can specify any test cases that will be used to check student's submission. </p>

CC BY-SA 4.0
2019-08-08T15:15:33.747Z
Could you elaborate on this answer, maybe with some more explanation as to why you think Stepik is the correct answer to the question?
thesecretmaster
CC BY-SA 3.0
2017-10-18T10:43:30.780Z
2017-10-18T10:43:30.780Z
Anastasia Samsonova
<p>Yikes, that doesn't sound like a fun way to grade. Sounds about like what I do with students that are competing in <a href="http://acsl.org" rel="noreferrer">ACSL</a> competitions. But that's only 6 or 7 students, 4 times a year. I can't imagine trying it with 100 students all year. </p>

<p>Here's what I'm doing, and what I've done.</p>

<p><strong>Online Autograder</strong></p>

<p>This is what I'm doing now. Kids login to Canvas and it launches an LTI tool embedded in an assignment. They do their coding in Chrome and click the Test button when they're ready. They can keep testing until their happy with the grade. Grades get sent back to Canvas. I still have to transfer them to our actual gradebook. </p>

<p>I can then go back and download the submissions if I want to look at them for style or tips. Generally I try and do this with everybody on at least one lab per lab set. </p>

<p>What I've found is that students average about 11 submissions before they move on to the next lab. I only grade the last one, although I'll go back and look to see how they progressed. </p>

<p>Downside to this is that it works well for smaller labs, but not as much with larger projects. I can break down large projects into pieces that they can check, but eventually there has to be a full project turned in. </p>

<p><strong>JUnit Tests</strong></p>

<p>Before I moved online I would write a JUnit test for every lab, and usually I'd write two. One that I would include with the starter code and one, more in depth, that I would use to test. </p>

<p>Students could run the test code as many times as they wanted. Then, they'd submit their solutions and I'd run it against the other test code. </p>

<p>Biggest downside is it was pretty time consuming to write unit tests for every lab. I've gotten pretty quick, but it's still a time suck.</p>

<p><strong>Walk around</strong></p>

<p>Not ideal, but I can pick up a lot about students' code by walking around the room and watching them code. </p>

<p>I do this a lot with projects to get a feel for where the kids are on the project. By the time it's turned in I've already got a pretty good idea on what they've done.</p>

<p>Doesn't scale well though. Biggest class I've ever had was 34 students. </p>

<p><strong>"Participation Grades"</strong></p>

<p>Sometimes I fall into this trap, especially with my second and third year students. I give them labs, they work on their labs, and I assume that they're done correctly if they've been working in class. </p>

<p>Only saving grace on this one is that labs are worth very little and tests make up a majority of their averages. So even with gimmie grades on labs, they can still get hammered on the tests.</p>

<p>Admittedly not a good solution, and one that I'm trying to work my way out of next year. </p>

<p><strong>Eyeball It</strong></p>

<p>Skim the code and see if you think it works. Same as the participation, this only really works with smaller assignments and when labs aren't worth all that much. </p>

CC BY-SA 3.0
2017-06-29T17:46:01.227Z
I really like that you are using Online AutoGrader as an option. When we tried similar options, the issue was that students worked in a 'fake' environment i.e. their browser. We wanted to make sure they were learning to use the right tools such as their IDEs, learn debugging in them etc.
tusharsoni
CC BY-SA 3.0
2017-06-29T17:53:02.087Z
Indeed. It works better for small-ish lab type assignments, not as much for projects. On some projects though I'll break them into pieces and have them submit each piece online for testing. By the time they turn in their full project I've already got a decent idea of how their code is going to work.  That said, I've found the opposite of the fake environment problem. Being a primitive IDE without any help makes the focus on the problem and helps learn the methods.
Ryan Nutt
CC BY-SA 3.0
2017-10-20T14:06:04.603Z
Which Canvas LTI tool do you use for the kids to write and test in Chrome?
iFrame
CC BY-SA 3.0
2017-10-20T14:25:07.827Z
It's one I wrote because I couldn't find something that I liked. There's a link in my profile.
Ryan Nutt
CC BY-SA 3.0
2017-06-29T01:49:45.480Z
2017-06-29T01:49:45.480Z
Ryan Nutt
<p>The degree of automation that you can achieve depends on how you want to grade. The most valuable type of grading (to a student) does not only cover whether the code works or not, but also offers suggestions as to how to make it better, including readability, design, and so no. And that you cannot totally automate. </p>

<p>You can (and should) automate basic setups, compilation, and  tests, and generally remove as much grading-boilerplate as possible via automation. Todo so, the first step is to make sure that students will follow certain reproducibility guidelines. In my case,</p>

<ul>
<li><p>The instructions for assignments always include a <strong>specific test environment and test command</strong>, that <em>must</em> run. So for example, this could be "jdk 1.7 as installed in the lab" + "javac of your .java files". This allows me to ignore "works for me in my place" excuses -- unless it works in the test environment, it will not receive a passing grade. Note that this is generally not a the development environment; that may be eclipse or whichever other IDE they choose. I generally try to stick to the lowest common bare-metal standard.</p></li>
<li><p>JUnit or other <strong>unit-testing</strong> frameworks are great to assert minimal performance. You can either request them to write their own tests (make sure to specify what these should cover), or provide them with pre-written tests (more effort, but hopefully more in-depth testing). Ryan Nutt's <a href="https://cseducators.stackexchange.com/a/1208/913">answer</a> also offers good suggestions. Unit-testing is huge not only because it helps you to grade, but also because it makes students aware of their own errors; they will then fix these errors <em>before</em> submitting the assignments, which is a clear win-win.</p></li>
<li><p>Mandating <strong>command-line</strong> friendly <strong>build tools</strong> (maven, scons, makefiles, scripts, ...) really helps to quickly pass the above tests.</p></li>
<li><p>Students must use an online submission system (eg.: Moodle task) to upload their code.</p></li>
</ul>

<p>Afterwards, in my grading setup, </p>

<ul>
<li><p>I download all submissions for the assignment, and each will be nicely tucked into files named after the uploading student. I then run a small shell script that extracts each submission into a single folder. After significant frustration, the script has been tweaked to deal with .7z, .rar, and .tgz archives instead of the requested .zip files. </p></li>
<li><p>I write small per-assignment scripts that I can point at a submission and will </p>

<ol>
<li>open my favorite IDE pointing at the submission</li>
<li>compare it side-by-side with previous submissions by the same author, assuming that this is an incremental project, using meld or a similar visual diff tool.</li>
<li>launch any corresponding unit tests to see if anything fails</li>
</ol></li>
<li><p>I then write a per-assignment check-list of items that I want to look at in each submission. This gets refined until I have graded 5 or so, when it sort of stabilizes. </p></li>
<li><p>Finally, I get to grade the bulk of submissions, writing comments for students as I go, and often copying and pasting comments from previous submissions. When all are graded (and not before, because I sometimes have to backtrack or refine grading criteria), I copy-and-paste comments and grades to the online submission tool so that students can see them. The most frequent mistakes make the bulk of the next lecture.</p></li>
</ul>

<p>So essentially I recommend standardizing as much as possible, and investing some time into per-assignment automation, in order to speed up actual grading. </p>

CC BY-SA 3.0
2017-06-29T17:43:19.573Z
Thanks for your answer! Specifying a version for JDK definitely works for Java across platforms but other languages such as C++, C are platform dependent. Students write platform dependent code that works on their computer and doesn't on a different platform.
tusharsoni
CC BY-SA 3.0
2017-06-29T17:44:40.347Z
Your grading setup seems organized but still has a lot of manual work. We eventually ended up investing the time to automate all of that. Saved TAs and instructors a bunch of time
tusharsoni
CC BY-SA 4.0
2020-10-17T15:23:50.283Z
Yes, I think your process is good except that the .zip format should be handled by the submission tool.
Josiah Yoder
CC BY-SA 4.0
2020-10-17T16:44:41.843Z
@JosiahYoder I fully agree - at the time of writing the answer, however, the submission tool for our (mandatory) LMS had no option to specify file type. Even now, some students think that changing the file's extension also changes its format ("hey, my .rar file is not accepted, let me rename it to .zip so I can turn it in")
tucuxi
CC BY-SA 3.0
2017-06-29T13:55:22.930Z
2017-06-29T13:55:22.930Z
tucuxi
<p>The key to efficient grading of assignments is to build easily gradable assignments in the first place. This does <em>not</em> imply easier problems, but, as unit testing makes code testable, this kind of discipline makes assignments gradable. Like many of the suggestions here, JUnit test cases are an important factor, but to use them you need to more completely specify the assignment (e.g. what functions/methods to write, etc.) For higher level grading, you can build a facade method that takes a big string as input.</p>

<p>There are two tools that I use for auto-grading of assignments: <a href="https://repl.it/site/classrooms" rel="noreferrer">repl.it classroom</a> and <a href="http://web-cat.cs.vt.edu/Web-CAT/WebObjects/Web-CAT.woa" rel="noreferrer">Web-CAT</a>.</p>

<ul>
<li>Repl.it classroom is good for small assignments. It's a SaaS-based development environment that supports dozens of different languages. You can set up a course and put assignments in it complete with descriptions, test cases (unit-test or output-based), and progress reporting. Repl.it also supports LTI integration for most course management systems like Moodle, Blackboard, Canvas, etc. This is fantastic for homework.</li>
<li>Web-CAT is good for large lab assignments. Students code in their own IDE (Eclipse, BlueJ, etc) and then submit the files for automatic grading. This uses JUnit heavily, although there are some plugins for output-based grading. Web-CAT is highly opinionated and wants students to write their own test cases and testing metrics are part of the students' grades. You can get access to Web-CAT for your institution through <a href="http://www.cs.vt.edu/user/edwards/" rel="noreferrer">Stephen Edwards</a> at Virginia Tech or you can <a href="https://sourceforge.net/projects/web-cat/" rel="noreferrer">download and install it</a> on your own server.</li>
</ul>

<p>See also, <a href="https://cseducators.stackexchange.com/questions/2/what-autograding-software-do-folks-use-for-java-code/">this similar thread</a>.</p>

CC BY-SA 4.0
2020-10-17T15:25:55.307Z
Even if you do not use unit tests, having specified method names can make it easier to focus on part of the assignment. The downside is that this restricts the design so students get less practice doing design work.
Josiah Yoder
CC BY-SA 3.0
2017-06-30T18:01:15.003Z
2017-06-30T18:01:15.003Z
Todd Whittaker
<p>These are some popular tools that the community should look into for a reasonable grading setup:</p>

<ul>
<li><a href="https://autogradr.com" rel="nofollow noreferrer">AutoGradr.com</a> (Disclaimer: I'm one of the authors of this free tool)</li>
<li>HackerRank.com</li>
<li>domjudge.org</li>
<li>mooshak.dcc.fc.up.pt</li>
</ul>

CC BY-SA 4.0
2019-05-14T18:38:35.600Z
So, did you develop your tool in response to the problems you were having at the time you wrote this question?
Ben I.
CC BY-SA 4.0
2019-05-15T19:08:09.967Z
Yup! I was a TA and built this project to solve this problem. Now we have a community of hundreds of professors using this solution to improve their course.
tusharsoni
CC BY-SA 4.0
2019-05-15T21:25:27.790Z
@tusharoni Does the contact email on the website currently go to you? (And would you object if I contacted you?)
Ben I.
CC BY-SA 4.0
2019-05-16T01:43:01.660Z
Yup, go for it!
tusharsoni
CC BY-SA 4.0
2019-08-06T07:54:05.993Z
On similar lines to HackerRank, there's SPOJ (Sphere Online Judge): on a quick look, I don't see that they make their backend software available, but maybe if you ask. If you ask in the codegolf chatroom The Nineteenth Hole then people may be able to suggest other sites which have automatic golf validation setups.
Peter Taylor
CC BY-SA 4.0
2019-05-14T16:03:41.447Z
2019-05-14T16:03:41.447Z
tusharsoni
<p><em>(I am submitting 2 answers, because they are very different takes on the same problem, and merging them together would be of little value)</em></p>

<p>This is a full-automation setup I have used in a C++ data-structures subject.</p>

<ul>
<li><p>Install an automated answer judge (say, <a href="https://www.domjudge.org/" rel="nofollow noreferrer">domjudge</a> or <a href="https://mooshak.dcc.fc.up.pt/" rel="nofollow noreferrer">mooshack</a>). Setup username/password pairs for each of your students. Configure the judge to only accept answers in your chosen programming language.</p></li>
<li><p>Provide your students with exact specifications of the compilation environment used by the judge. If you want full build reproducibility, run the judges on virtual machines and provide copies of these to your students; however, specifying the exact compiler version and OS is generally enough.</p></li>
<li><p>Spend significant time preparing each problem statement, resource limits (time and memory), and the sample and validation inputs and outputs. (Great) examples of problems designed for automated judging can be found at the <a href="https://uva.onlinejudge.org/" rel="nofollow noreferrer">UVA site</a>. Note that they come without validation inputs and outputs; I have not found open repositories with full questions, but there are several repositories of enthusiast users with working answers.</p></li>
<li><p>Open the contest and watch the answers roll in. Be prepared to find &amp; fix errors in the problem statement or input/output files unless you were very, very careful when writing them.</p></li>
</ul>

<p>Fully-automatic validation leaves no room for error on either your part (statement, input-output specs) or the student's (off-by-a-comma is a wrong answer). For these reasons I recommend pairing up with someone who can double-check that statements are clear and that tries to solve problems before opening time.</p>

<p>To prepare a single statement, I generally</p>

<ul>
<li>write a draft of the statement, with sample input and output</li>
<li>code a reference answer</li>
<li>code an input-generator that can create valid but random inputs of configurable sizes</li>
<li>generate a few nice-looking inputs and run them through the reference answer to get the validation input-output pairs</li>
</ul>

<p>It is a lot of work (around 2hrs for each problem, QA included); but afterwards marginal grading cost is effectively 0.</p>

<p>Note that nothing prevents students from copying each other's answers (although you could run answers through a plagiarism-detection program). You should be aware that cheating unless conditions are tightly controlled is quite easy.</p>

CC BY-SA 3.0
2017-06-30T13:38:01.757Z
2017-06-30T13:44:20.453Z
2017-06-30T13:44:20.453Z
tucuxi
<p>As a TA, the usual workflow for grading programming assignments for an introductory course would be:</p>

<ol>
<li>Some instructors used email as a submission mechanism (yes, really.)</li>
<li>So, search for submissions in email and download every submission</li>
<li>Organize it to make grading easier later on</li>
<li>Go into each directory, compile it. Realize it doesn't work.</li>
<li>If I email the student, I get a response 'Works on my computer'</li>
<li>Debug it and make it compile on my computer</li>
<li>Due to lack of test cases, every student has demonstrated their work with their own version of output on the console</li>
<li>Decipher their output and hopefully they get a good grade</li>
<li>Partial grading is hard because I have to dig through the code and see what parts are done and how far away they are from a working solution</li>
</ol>

<p>All in all, it takes about 7-10 minutes per submission <em>if</em> I do things carefully. 100 students, 3 programming problems = 300 submissions. 10 mins per submission = 3000 minutes = 2 days of continuous grading. Impossible.</p>

<p>I have heard instructors make scripts, use some tools. Sometimes, they get super strict on the output of the program so they can grade it easily. Worse, they make problems easier so it's easier to grade.</p>

<p>How can I automate this efficiently?</p>

CC BY-SA 3.0
2017-06-28T23:33:53.650Z
Shouldn't you never have to debug your students work? If it doesn't compile, it seems like that is non working code, and an incomplete assignment.
thesecretmaster
CC BY-SA 3.0
2017-06-28T23:39:02.177Z
If you take C++ code that runs on Windows, it may not necessarily run on MacOS if it has platform dependent code. Introductory students make these mistakes all the time.
tusharsoni
CC BY-SA 3.0
2017-06-29T01:51:22.890Z
I probably wouldn't worry about 5 or 6. I'd leave it with "it doesn't work, come see me if you want to talk." On labs I don't worry about partial credit. It either works or it doesn't.
Ryan Nutt
CC BY-SA 3.0
2017-06-29T21:11:28.423Z
My university program had linux servers available for use in labs and remotely via SSH. All of our code had to compile on a specific server (which  we could not install packages on) and were submitted into a directory on said server. It made the acquiring of code and execution environment very simple to manage.
Brian R
CC BY-SA 3.0
2017-06-30T11:59:28.300Z
just an fyi: https://www.hackerrank.com/ is another online tool which also bridge the gap between academics and industry. Some employers use as first technical round when looking for new hires.
lithiumhead
CC BY-SA 3.0
2017-06-30T17:10:29.337Z
Generally, it's best not to put a summary of the answers in a question. If you think a summary answer would add value, feel free to answer your own question instead to allow others to vote on it and edit it separately to your question.
Aurora0001
CC BY-SA 4.0
2019-04-22T01:31:01.430Z
@tusharsoni did you find a solution? I have a similar case
Aksakal almost surely binary
CC BY-SA 4.0
2019-05-14T16:00:41.620Z
@aksakal Try [AutoGradr.com](https://autogradr.com)
tusharsoni
<grading><auto-graders>
How can I automate the grading of programming assignments?
# How can I automate the grading of programming assignments?

(Asked by: username_0 on 2017-06-28)

As a TA, the usual workflow for grading programming assignments for an introductory course would be:

1. Some instructors used email as a submission mechanism (yes, really.)
2. So, search for submissions in email and download every submission
3. Organize it to make grading easier later on
4. Go into each directory, compile it. Realize it doesn't work.
5. If I email the student, I get a response 'Works on my computer'
6. Debug it and make it compile on my computer
7. Due to lack of test cases, every student has demonstrated their work with their own version of output on the console
8. Decipher their output and hopefully they get a good grade
9. Partial grading is hard because I have to dig through the code and see what parts are done and how far away they are from a working solution

All in all, it takes about 7-10 minutes per submission *if* I do things carefully. 100 students, 3 programming problems = 300 submissions. 10 mins per submission = 3000 minutes = 2 days of continuous grading. Impossible.

I have heard instructors make scripts, use some tools. Sometimes, they get super strict on the output of the program so they can grade it easily. Worse, they make problems easier so it's easier to grade.

How can I automate this efficiently?

**Tags:** grading, auto-graders

> **Comments:**
> **username_1**: Shouldn't you never have to debug your students work? If it doesn't compile, it seems like that is non working code, and an incomplete assignment.  
> **username_0**: If you take C++ code that runs on Windows, it may not necessarily run on MacOS if it has platform dependent code. Introductory students make these mistakes all the time.  
> **username_2**: I probably wouldn't worry about 5 or 6. I'd leave it with "it doesn't work, come see me if you want to talk." On labs I don't worry about partial credit. It either works or it doesn't.  
> **username_3**: My university program had linux servers available for use in labs and remotely via SSH. All of our code had to compile on a specific server (which  we could not install packages on) and were submitted into a directory on said server. It made the acquiring of code and execution environment very simple to manage.  
> **username_4**: just an fyi: https://www.hackerrank.com/ is another online tool which also bridge the gap between academics and industry. Some employers use as first technical round when looking for new hires.  
> **username_5**: Generally, it's best not to put a summary of the answers in a question. If you think a summary answer would add value, feel free to answer your own question instead to allow others to vote on it and edit it separately to your question.  
> **username_6**: @username_0 did you find a solution? I have a similar case  
> **username_0**: @aksakal Try [AutoGradr.com](https://autogradr.com)  

---

## 11 answers

### Answer by username_15 on 2017-06-29. Score: 18

The degree of automation that you can achieve depends on how you want to grade. The most valuable type of grading (to a student) does not only cover whether the code works or not, but also offers suggestions as to how to make it better, including readability, design, and so no. And that you cannot totally automate.

You can (and should) automate basic setups, compilation, and tests, and generally remove as much grading-boilerplate as possible via automation. Todo so, the first step is to make sure that students will follow certain reproducibility guidelines. In my case,

* The instructions for assignments always include a **specific test environment and test command**, that *must* run. So for example, this could be "jdk 1.7 as installed in the lab" + "javac of your .java files". This allows me to ignore "works for me in my place" excuses -- unless it works in the test environment, it will not receive a passing grade. Note that this is generally not a the development environment; that may be eclipse or whichever other IDE they choose. I generally try to stick to the lowest common bare-metal standard.
* JUnit or other **unit-testing** frameworks are great to assert minimal performance. You can either request them to write their own tests (make sure to specify what these should cover), or provide them with pre-written tests (more effort, but hopefully more in-depth testing). username_2's [answer](https://cseducators.stackexchange.com/a/1208/913) also offers good suggestions. Unit-testing is huge not only because it helps you to grade, but also because it makes students aware of their own errors; they will then fix these errors *before* submitting the assignments, which is a clear win-win.
* Mandating **command-line** friendly **build tools** (maven, scons, makefiles, scripts, ...) really helps to quickly pass the above tests.
* Students must use an online submission system (eg.: Moodle task) to upload their code.

Afterwards, in my grading setup,

* I download all submissions for the assignment, and each will be nicely tucked into files named after the uploading student. I then run a small shell script that extracts each submission into a single folder. After significant frustration, the script has been tweaked to deal with .7z, .rar, and .tgz archives instead of the requested .zip files.
* I write small per-assignment scripts that I can point at a submission and will

  1. open my favorite IDE pointing at the submission
  2. compare it side-by-side with previous submissions by the same author, assuming that this is an incremental project, using meld or a similar visual diff tool.
  3. launch any corresponding unit tests to see if anything fails
* I then write a per-assignment check-list of items that I want to look at in each submission. This gets refined until I have graded 5 or so, when it sort of stabilizes.
* Finally, I get to grade the bulk of submissions, writing comments for students as I go, and often copying and pasting comments from previous submissions. When all are graded (and not before, because I sometimes have to backtrack or refine grading criteria), I copy-and-paste comments and grades to the online submission tool so that students can see them. The most frequent mistakes make the bulk of the next lecture.

So essentially I recommend standardizing as much as possible, and investing some time into per-assignment automation, in order to speed up actual grading.

> **Comments:**
> **username_0**: Thanks for your answer! Specifying a version for JDK definitely works for Java across platforms but other languages such as C++, C are platform dependent. Students write platform dependent code that works on their computer and doesn't on a different platform.  
> **username_0**: Your grading setup seems organized but still has a lot of manual work. We eventually ended up investing the time to automate all of that. Saved TAs and instructors a bunch of time  
> **username_16**: Yes, I think your process is good except that the .zip format should be handled by the submission tool.  
> **username_15**: @JosiahYoder I fully agree - at the time of writing the answer, however, the submission tool for our (mandatory) LMS had no option to specify file type. Even now, some students think that changing the file's extension also changes its format ("hey, my .rar file is not accepted, let me rename it to .zip so I can turn it in")  

---

### Answer by username_2 on 2017-06-29. Score: 9

Yikes, that doesn't sound like a fun way to grade. Sounds about like what I do with students that are competing in [ACSL](http://acsl.org) competitions. But that's only 6 or 7 students, 4 times a year. I can't imagine trying it with 100 students all year.

Here's what I'm doing, and what I've done.

**Online Autograder**

This is what I'm doing now. Kids login to Canvas and it launches an LTI tool embedded in an assignment. They do their coding in Chrome and click the Test button when they're ready. They can keep testing until their happy with the grade. Grades get sent back to Canvas. I still have to transfer them to our actual gradebook.

I can then go back and download the submissions if I want to look at them for style or tips. Generally I try and do this with everybody on at least one lab per lab set.

What I've found is that students average about 11 submissions before they move on to the next lab. I only grade the last one, although I'll go back and look to see how they progressed.

Downside to this is that it works well for smaller labs, but not as much with larger projects. I can break down large projects into pieces that they can check, but eventually there has to be a full project turned in.

**JUnit Tests**

Before I moved online I would write a JUnit test for every lab, and usually I'd write two. One that I would include with the starter code and one, more in depth, that I would use to test.

Students could run the test code as many times as they wanted. Then, they'd submit their solutions and I'd run it against the other test code.

Biggest downside is it was pretty time consuming to write unit tests for every lab. I've gotten pretty quick, but it's still a time suck.

**Walk around**

Not ideal, but I can pick up a lot about students' code by walking around the room and watching them code.

I do this a lot with projects to get a feel for where the kids are on the project. By the time it's turned in I've already got a pretty good idea on what they've done.

Doesn't scale well though. Biggest class I've ever had was 34 students.

**"Participation Grades"**

Sometimes I fall into this trap, especially with my second and third year students. I give them labs, they work on their labs, and I assume that they're done correctly if they've been working in class.

Only saving grace on this one is that labs are worth very little and tests make up a majority of their averages. So even with gimmie grades on labs, they can still get hammered on the tests.

Admittedly not a good solution, and one that I'm trying to work my way out of next year.

**Eyeball It**

Skim the code and see if you think it works. Same as the participation, this only really works with smaller assignments and when labs aren't worth all that much.

> **Comments:**
> **username_0**: I really like that you are using Online AutoGrader as an option. When we tried similar options, the issue was that students worked in a 'fake' environment i.e. their browser. We wanted to make sure they were learning to use the right tools such as their IDEs, learn debugging in them etc.  
> **username_2**: Indeed. It works better for small-ish lab type assignments, not as much for projects. On some projects though I'll break them into pieces and have them submit each piece online for testing. By the time they turn in their full project I've already got a decent idea of how their code is going to work.  That said, I've found the opposite of the fake environment problem. Being a primitive IDE without any help makes the focus on the problem and helps learn the methods.  
> **username_14**: Which Canvas LTI tool do you use for the kids to write and test in Chrome?  
> **username_2**: It's one I wrote because I couldn't find something that I liked. There's a link in my profile.  

---

### Answer by username_17 on 2017-06-30. Score: 7

The key to efficient grading of assignments is to build easily gradable assignments in the first place. This does *not* imply easier problems, but, as unit testing makes code testable, this kind of discipline makes assignments gradable. Like many of the suggestions here, JUnit test cases are an important factor, but to use them you need to more completely specify the assignment (e.g. what functions/methods to write, etc.) For higher level grading, you can build a facade method that takes a big string as input.

There are two tools that I use for auto-grading of assignments: [repl.it classroom](https://repl.it/site/classrooms) and [Web-CAT](http://web-cat.cs.vt.edu/Web-CAT/WebObjects/Web-CAT.woa).

* Repl.it classroom is good for small assignments. It's a SaaS-based development environment that supports dozens of different languages. You can set up a course and put assignments in it complete with descriptions, test cases (unit-test or output-based), and progress reporting. Repl.it also supports LTI integration for most course management systems like Moodle, Blackboard, Canvas, etc. This is fantastic for homework.
* Web-CAT is good for large lab assignments. Students code in their own IDE (Eclipse, BlueJ, etc) and then submit the files for automatic grading. This uses JUnit heavily, although there are some plugins for output-based grading. Web-CAT is highly opinionated and wants students to write their own test cases and testing metrics are part of the students' grades. You can get access to Web-CAT for your institution through [Stephen Edwards](http://www.cs.vt.edu/user/edwards/) at Virginia Tech or you can [download and install it](https://sourceforge.net/projects/web-cat/) on your own server.

See also, [this similar thread](https://cseducators.stackexchange.com/questions/2/what-autograding-software-do-folks-use-for-java-code/).

> **Comments:**
> **username_16**: Even if you do not use unit tests, having specified method names can make it easier to focus on part of the assignment. The downside is that this restricts the design so students get less practice doing design work.  

---

### Answer by username_15 on 2017-06-30. Score: 4

*(I am submitting 2 answers, because they are very different takes on the same problem, and merging them together would be of little value)*

This is a full-automation setup I have used in a C++ data-structures subject.

* Install an automated answer judge (say, [domjudge](https://www.domjudge.org/) or [mooshack](https://mooshak.dcc.fc.up.pt/)). Setup username/password pairs for each of your students. Configure the judge to only accept answers in your chosen programming language.
* Provide your students with exact specifications of the compilation environment used by the judge. If you want full build reproducibility, run the judges on virtual machines and provide copies of these to your students; however, specifying the exact compiler version and OS is generally enough.
* Spend significant time preparing each problem statement, resource limits (time and memory), and the sample and validation inputs and outputs. (Great) examples of problems designed for automated judging can be found at the [UVA site](https://uva.onlinejudge.org/). Note that they come without validation inputs and outputs; I have not found open repositories with full questions, but there are several repositories of enthusiast users with working answers.
* Open the contest and watch the answers roll in. Be prepared to find & fix errors in the problem statement or input/output files unless you were very, very careful when writing them.

Fully-automatic validation leaves no room for error on either your part (statement, input-output specs) or the student's (off-by-a-comma is a wrong answer). For these reasons I recommend pairing up with someone who can double-check that statements are clear and that tries to solve problems before opening time.

To prepare a single statement, I generally

* write a draft of the statement, with sample input and output
* code a reference answer
* code an input-generator that can create valid but random inputs of configurable sizes
* generate a few nice-looking inputs and run them through the reference answer to get the validation input-output pairs

It is a lot of work (around 2hrs for each problem, QA included); but afterwards marginal grading cost is effectively 0.

Note that nothing prevents students from copying each other's answers (although you could run answers through a plagiarism-detection program). You should be aware that cheating unless conditions are tightly controlled is quite easy.


---

### Answer by username_0 on 2019-05-14. Score: 3

These are some popular tools that the community should look into for a reasonable grading setup:

* [AutoGradr.com](https://autogradr.com) (Disclaimer: I'm one of the authors of this free tool)
* HackerRank.com
* domjudge.org
* mooshak.dcc.fc.up.pt

> **Comments:**
> **username_10**: So, did you develop your tool in response to the problems you were having at the time you wrote this question?  
> **username_0**: Yup! I was a TA and built this project to solve this problem. Now we have a community of hundreds of professors using this solution to improve their course.  
> **username_10**: @tusharoni Does the contact email on the website currently go to you? (And would you object if I contacted you?)  
> **username_0**: Yup, go for it!  
> **username_12**: On similar lines to HackerRank, there's SPOJ (Sphere Online Judge): on a quick look, I don't see that they make their backend software available, but maybe if you ask. If you ask in the codegolf chatroom The Nineteenth Hole then people may be able to suggest other sites which have automatic golf validation setups.  

---

### Answer by username_7 on 2019-06-09. Score: 2

I have seen universities use linters and test suites to automatically check the correct state of the assignment so it can be submitted. Here is an example in [Python](http://www.krivers.net/15112-f17/notes/cs112_f17_linter.py) or the student assignment [helper programs](http://csapp.cs.cmu.edu/3e/datalab-handout.tar) in C, used for the book CS:App as another example of possible small programs you could include with assignments to make this easier to review submissions.


---

### Answer by username_8 on 2019-02-14. Score: 1

I used [stepik.org](https://stepik.org) for my functional programming lab (in Java). It works like a charm.
As for me, the only missing part is plagiarism detection. I believe you should it give it a go!

With stepik, you have the features of a basic LMS (learning management system). Basically you can publish an online course (with several chapters..); you can get "students" to join the course, publish assignments; if needed define time window to submit assignments.

Among assignments (quizzes, Fill in the blanks, ...), it is possible to set up code assignments. For the code assignment, most of popular programming languages are possible (including Java, Python, C/C++, SQL, ...).

In order to assess an assignment, you need to define a test case. Typically, inputs are read from the console (for instance using `new Scanner(System.in).nextLine()` in Java), then the student's solution output needs to match the expected output defined for the test case.

More details can be found in [stepik assignement types](https://support.stepik.org/hc/en-us/articles/360000159673-Types-of-assignments)


---

### Answer by username_9 on 2022-05-12. Score: 1

My development team (Mrs Marsupial) implemented an application and later a server (because COVID necessitated more remote learning) that solves a lot of these difficulties. The student uploads their code and the server compiles and runs their code (fairly securely using docker) and the uses LaTeX to generate a .PDF file containing (i) their code suitably formatted and with the files in the correct order; (ii) any compile messages; (iii) the output of their program and (iv) any messages sent to stderr by their program. Most of the time, if the program works correctly you can just get on with marking the program and adding feedback (I use an ipad to annotate the pdf directly, more time consuming than annotating paper, but still reasonable). For each module there is am XML file of metadata specifying what files are needed, which data files should be downloaded for testing the program and output files that should be included in the .PDF.

If the program doesn't work, the .pdf file contains an embedded .zip file containing the code (in a consistent format) so the marker can extract the code and investigate the problem.

This has reduced marking time very substantially and the students seem to like it as well as they can see exactly what the marker sees (no more "it works on my computer") and also the server keeps a reliably time-stamped record of what was uploaded in case of problems later and the students are encouraged to make regular provisional submissions (no more "my hard drive failed" etc.)

We are looking to add extra features such as plagiarism detection and more automated code analysis. However, a lot of programming is not whether the computer understands the code, but whether a human reader does, so there are some aspects of programming that simply cannot be marked automatically (and when computers can do that, we probably won't need programmers anymore ;o)

P.S. I use a simple BASH script to email the feedback to the students, which is much easier than messing around with BlackBoard etc.

> **Comments:**
> **username_10**: I like this answer, though it sounds like a gargantuan effort to set up!  
> **username_9**: We developed it over a number of years, so it wasn't too bad (and was offset in the reduction in the amount of time I spend marking).  The biggest step was implementing it as a reasonably secure server, but that turned out to provide the greatest benefit.  I am very fortunate in having made a good choice of Mrs Marsupial (she is a much more productive programmer than I am ;o)  

---

### Answer by username_11 on 2017-10-21. Score: 0

Some interesting projects for those working with block-based languages (such as Scratch, Snap! and Blockly):

For Scratch, check out [Dr Scratch](http://www.drscratch.org/), which takes a rubric approach to evaluating how much 'computational thinking' is evidenced by a project. Whilst the analysis might seem a bit reductive, it can be used independently by learners and includes some useful guidance on how to progress. The developers describe their approach in [this paper](http://www.um.es/ead/red/46/moreno_robles.pdf). Dr Scratch is built on [Hairball](https://github.com/ucsb-cs-education/hairball), a Python module which does static analysis of Scratch projects.

A more conventional autograder, [lambda](https://github.com/cycomachead/lambda-evaluator), is being developed by Michael Ball for Snap! It's already integrated into UCB's [Beauty and Joy of Computing](http://bjc.berkeley.edu/) MOOC, and I think there are plans to make this more widely available. Michael wrote about this for [Hello World #3](https://s3-eu-west-1.amazonaws.com/rpi-magazines/issues/full_pdfs/000/000/004/original/HelloWorld03.pdf#page=26).

Chris Roffey has developed an autograder for Blockly used in the initial round of the [TCS Oxford Computing Challenge](https://challenge.tcsocc.uk/index.php?action=user_competitions) programming challenge, although I don't think the code for this is shared publicly.


---

### Answer by username_12 on 2017-10-23. Score: 0

> As a TA, the usual workflow for grading programming assignments for an
> introductory course would be:
>
> 1. Some instructors used email as a submission mechanism (yes, really.)

"*Yes, really*"? In the introductory course at my university we submitted our programs as printouts.

> If you take C++ code that runs on Windows, it may not necessarily run on MacOS if it has platform dependent code. Introductory students make these mistakes all the time.

It seems to me that the mistake is using C++ for an introductory course. Complete beginners do not need help shooting themselves in the foot. The curriculum may be out of your control, but if you have the option then teaching the introductory course either in a strongly typed LISP (SML, Haskell, or something similar) or at least in a concise portable language (Python, Ruby, etc.) should make it easier for both the students and the graders.


---

### Answer by username_13 on 2017-10-18. Score: -2

Please, take a look at [Stepik](http://stepik.org). Actually I myself work at Stepik, but if you're looking for a free cloud-based solution, it might be really useful for you. Code challenges are tested using stdin->stdout and you can specify any test cases that will be used to check student's submission.

> **Comments:**
> **username_1**: Could you elaborate on this answer, maybe with some more explanation as to why you think Stepik is the correct answer to the question?  

---

