Autograding Java code for computer science assignments
Guides
April 26, 2021

Webinar: How to automatically grade Java code and code quality

After the success of our previous webinar on Python Autograding, we answered the many requests to cover all ins and outs of Java Autograding in a webinar too. This Java Autograding webinar was part of our monthly focus groups (on April 23rd of 2021) and can be watched on demand now!

Creating a basic autograded Java assignment in CodeGrade

In the first part of this webinar, CodeGrade's founder and product expert Devin Hillenius discusses ways to design your basic autograded Java assignments in CodeGrade. He goes over three aspects: hand in requirements for Java, compiling Java code and I/O tests for Java.

  • Hand In Requirements are an important aspect of all CodeGrade assignments, but especially for the large projects with specific directory structure you have for Java assignments. Three tactics are discussed: denying all files and specifying the files you want in the root of the submission, allowing all files and denying any class files and denying all files and requiring specific folder structures (e.g. src/com/codegrade/Class1.java). A useful tip mentioned in the webinar is to turn off the "Delete leading directories" option for Java submissions in which folder structures are important.
  • Compiling Java code can be done in AutoTest in two ways, either in the per-student setup script or in a separate test. Doing it in the per-student setup script has the benefit that the compiled files are available in all categories, whereas in a separate test you can actually grade the compilation step too. An attentive viewer mentioned that these do not have to exclude each other, and that you can simply grade a compilation step by checking if the compiled files are present or not.
  • Finally, some easy Input and Output tests (I/O tests) are set up for our Sudoku Solver assignment.
Save time by autograding your Java assignments now!

Autograding Java Code Quality

Code Quality autograding is discussed in the second part of the webinar. The Code Quality steps in CodeGrade allow you to very easily use powerful tools to assess student code. In this webinar, Devin explains not only how you can use these powerful tools, but also how you can design your own style guide with custom messages, so that you can use these powerful tools in a very meaningful way that suits your class, your learning goals and the level of your students.

Two linters are discussed:

  • Checkstyle is a static code analysis tool to assess Java code. This tool can be used to check the presentation or "style" of code, and whether that conforms to the style guide you have set up or enforce. It does not check for actual correctness or completeness of code.
  • PMD, or Programming Mistake Detector, is a cross-language source code analyzer that works not only for Java, but also for JavaScript, XML and many other languages and frameworks. It does not detect bad presentation or style, but looks at code structures: inefficient code, bad programming habits and overcomplicated expressions.

Devin discusses many rules and checks that are very suitable for education, or specific courses, and shows how you can use them in your own custom style guide. The examples in this webinar are not meant as an exhaustive list, but rather as inspiration for your own style guide considerations for education. A separate blog on Code Quality in Java, with these lists, will be published on our website soon.

Advanced Java Autograding in CodeGrade

Finally, some more advanced ways of grading Java code are briefly shown. These topics have also been discussed in previous blogs or documentation:

This webinar and article point you in the right direction to set up your own automatic tests for your Java programming assignments. Of course, the possibilities with CodeGrade's AutoTest are endless. Would you like to learn more about setting up Java automatic grading for your code exercise? Feel free to email me at support@codegrade.com and I’d be more than happy to help out!

Continue reading

Start using CodeGrade now to supercharge your feedback on code.