https://github.com/sourcegrade/jagr
Java AutoGrader, Implemented in Kotlin
https://github.com/sourcegrade/jagr
grading java kotlin
Last synced: 5 months ago
JSON representation
Java AutoGrader, Implemented in Kotlin
- Host: GitHub
- URL: https://github.com/sourcegrade/jagr
- Owner: sourcegrade
- License: agpl-3.0
- Created: 2021-03-15T21:48:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-12-16T16:59:27.000Z (6 months ago)
- Last Synced: 2025-12-20T07:55:42.554Z (6 months ago)
- Topics: grading, java, kotlin
- Language: Kotlin
- Homepage: https://docs.sourcegrade.org/jagr/
- Size: 19.1 MB
- Stars: 27
- Watchers: 0
- Forks: 2
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: authors
Awesome Lists containing this project
README
Java AutoGrader, Implemented in Kotlin
A tool used to grade Java programs.
It is designed to accept graders and submissions created with the `jagr-gradle` plugin.
## Setup
This project's compiled, source and javadoc jars are hosted on [sonatype](https://s01.oss.sonatype.org).
Releases are available from `mavenCentral()` and snapshots from the maven
repository `maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")`.
Follow [this guide](https://docs.sourcegrade.org/development/getting-started/gradle-setup/) to set up your gradle buildscript.
## Usage
Create a basic `Criterion`:
```java
public static final Criterion H1_1 = Criterion.builder()
.shortDescription("Some short description")
.maxPoints(3) // default maxPoints is 1
.minPoints(-1) // default minPoints is 0
.grader(Grader.testAwareBuilder()
.requirePass(JUnitTestRef.ofMethod(() -> Tests.class.getMethod("testPositiveInts")))
.requirePass(JUnitTestRef.ofMethod(() -> Tests.class.getMethod("testNegativeInts")))
.pointsPassedMax() // award maximum points if ALL tests passed
.pointsFailedMin() // award minimum points if ANY test failed
.build())
.build();
```
Make sure your JUnit test classes are annotated as follows, or they will not run:
```java
@TestForSubmission
public class Test {
```
A `Criterion` may be nested as follows:
```java
public static final Criterion H1_1 = Criterion.builder()./*hidden*/.build();
public static final Criterion H1_2 = Criterion.builder()./*hidden*/.build();
public static final Criterion H1 = Criterion.builder()
.shortDescription("I have two child criteria!")
.addChildCriteria(H1_1, H1_2) // maxPoints, minPoints and grading is inferred from child criteria
.build();
```
Finally, create a `Rubric` and implement `RubricProvider`:
```java
public class H03_RubricProvider implements RubricProvider {
public static final Criterion H1_1 = Criterion.builder()./*hidden*/.build();
public static final Criterion H1_2 = Criterion.builder()./*hidden*/.build();
public static final Criterion H1 = Criterion.builder()./*hidden*/.build();
public static final Rubric RUBRIC = Rubric.builder()
.title("My example rubric")
.addChildCriteria(H1)
.build();
@Override
public Rubric getRubric() {
return RUBRIC;
}
}
```
## Running Jagr
To run Jagr, download the desired compiled release of Jagr from
[releases](https://github.com/sourcegrade/jagr/releases) and place it in a (preferably empty) directory of your choice.
Then either run the following command in a terminal of your choice (or write a batch/bash script that you can execute):
```bash
java -jar Jagr-VERSION.jar
```
Alternatively, you may run Jagr in-IDE via the Gradle `runShadow` task (the standard `run` task does not work).
The working directory used is `build/run`.
The following directories should have been created:
```
./graders // input folder for grader jars (tests and rubric providers)
./libs // for libraries that are required on each submission's classpath
./logs // saved log files
./rubrics // the output folder for graded rubrics
./submissions // input folder for submissions
./submissions-export // output folder for submissions
```
Place your grader jar(s) (tests and rubric providers) in `./graders` and the submission(s) you want to test
in `./submissions` and rerun Jagr.