Skip to content

Commit 370ddeb

Browse files
committed
Merge branch 'doc'
2 parents 83e8b28 + 3cdcc4a commit 370ddeb

8 files changed

+235
-15
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ classes/
1111
zips/
1212
*.iml
1313
*.puml
14-
doc/
1514
bin/
1615
jacocohtml/
1716
target/

CONTRIBUTING.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ For now, these are just some tips:
22

33
## Writing tests
44

5-
Contributions should include unit tests. In general, these should go in [src/test/java/com/spertus/jacquard](https://github.com/espertus/jacquard/tree/main/src/test/java/com/spertus/jacquard). There are a few exceptions...
5+
Contributions should include unit tests. In general, these should go in [src/test/java/com/spertus/jacquard](https://github.com/jacquard-autograder/jacquard/tree/main/src/test/java/com/spertus/jacquard). There are a few exceptions...
66

77
To test a method that would ordinarily be private, annotate it with the tag `@VisibleForTesting`, make the method package private, and put the test in the same package. [An example will be added soon.]
88

9-
If you are testing `JUnitTester`, put your test in the ordinary location, but put any tests it runs dynamically in [`src/test/java/com/spertus/jacquard/junittester`](https://github.com/espertus/jacquard/tree/main/src/test/java/com/spertus/jacquard/junittester) or a subdirectory,
10-
tagging the class `"IndirectTest"`. For example, see [`JUnitTesterTest.java`](https://github.com/espertus/jacquard/blob/main/src/test/java/com/spertus/jacquard/JUnitTesterTest.java), which dynamically runs [`SampleTest.java`](https://github.com/espertus/jacquard/tree/main/src/test/java/com/spertus/jacquard/junittester/SampleTest.java).
9+
If you are testing `JUnitTester`, put your test in the ordinary location, but put any tests it runs dynamically in [`src/test/java/com/spertus/jacquard/junittester`](https://github.com/jacquard-autograder/jacquard/tree/main/src/test/java/com/spertus/jacquard/junittester) or a subdirectory,
10+
tagging the class `"IndirectTest"`. For example, see [`JUnitTesterTest.java`](https://github.com/jacquard-autograder/jacquard/blob/main/src/test/java/com/spertus/jacquard/JUnitTesterTest.java), which dynamically runs [`SampleTest.java`](https://github.com/jacquard-autograder/jacquard/tree/main/src/test/java/com/spertus/jacquard/junittester/SampleTest.java).
1111

1212
## Running Tests
1313

@@ -17,16 +17,19 @@ these should be moved to `resources/`. These classes, which include [SampleTest]
1717
are tagged with `"IndirectTest"`, which causes them to be ignored when running the Gradle `test` task.
1818

1919
![IntelliJ Gradle panel screenshot with the task "test" in the "verification" section
20-
selected](https://github.com/espertus/jacquard/assets/661056/5f33dcb0-76ab-4e4e-80e5-bf344c7a0ab9)
20+
selected](images/run-tests.png)
2121

2222

2323
## build.gradle
24-
IntelliJ sometimes grays out most of `build.gradle`. If this happens, select `Reload All Gradle Projects` (the circular icon in the top left
25-
of the [Gradle panel screenshot](https://github.com/espertus/jacquard/assets/661056/5f33dcb0-76ab-4e4e-80e5-bf344c7a0ab9).
26-
[[Stack Overflow](https://stackoverflow.com/a/60207549/631051)].
24+
IntelliJ sometimes grays out most of `build.gradle`. If this happens, select the circular arrows icon
25+
`Reload All Gradle Projects` in the Gradle panel:
26+
27+
28+
![IntelliJ Gradle panel screenshot showing circular arrows icon with hover text "Reload All Gradle Projects"](images/reload-all-gradle-projects.png)
2729

2830
Publishing to Maven Central (Sonatype) requires a secret key, which is not part
2931
of the distribution. It is stored in `settings.gradle`.
3032

3133
## Javadoc
32-
Javadoc is automatically generated through a github action and pushed to [https://ellenspertus.com/jacquard/index.html](https://ellenspertus.com/jacquard/index.html) when changes are merged into `main`.
34+
Javadoc is automatically generated through a github action and pushed to [https://jacquard.ellenspertus.com](https://jacquard.ellenspertus.com)
35+
when changes are merged into `main`.

README.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Jacquard
22

3-
This is a Java autograder released in
4-
late summer 2023. While most of it is platform-independent, it will
5-
include Gradescope integration. I would be happy to get collaborators
6-
familiar with other systems this could hook into.
3+
Jacquard is a Java autograder developed at Northeastern University
4+
with Gradescope integration.
75

8-
Features include:
6+
## Features
97

108
* Syntax-based analysis using [JavaParser](https://github.com/javaparser/javaparser)
119
* Static analysis with [Checkstyle](https://checkstyle.org/) and
@@ -21,7 +19,28 @@ Features include:
2119

2220
For more information, see [Jacquard Examples](https://github.com/espertus/jacquard-examples).
2321

22+
## User Information
23+
24+
* [Javadoc](https://jacquard.ellenspertus.com/)
25+
* [FAQ](doc/FAQ.md)
26+
* [User Guide](doc/Guide.md) (incomplete)
27+
* Examples
28+
* [Jacquard Example 0](https://github.com/jacquard-autograder/jacquard-example0), which shows how to grade based on Checkstyle, PMD, and JUnit 5 tests.
29+
* [Jacquard Example 1](https://github.com/jacquard-autograder/jacquard-example1), which adds grading based on the parse tree, such as whether students
30+
use certain language features and methods.
31+
* Groups
32+
* [jacquard-announce](https://groups.google.com/g/jacquard-announce)
33+
* [jacquard-discuss](https://groups.google.com/g/jacquard-discuss)
34+
35+
## Information for Contributors
36+
37+
I welcome contributors, especially ones interested in integrating Jacquard with learning
38+
management systems (LMSs) and GitHub Class.
39+
40+
See [tips for contributors](CONTRIBUTING.md).
41+
42+
## Credits
2443
Jacquard was influenced by Tim Kutcher's [JGrade](https://github.com/tkutcher/jgrade) and
2544
includes some of its `Visibility` and `GradedTest` code.
2645

27-
[![Javadoc](https://img.shields.io/badge/JavaDoc-Online-green)](https://www.ellenspertus.com/jacquard/docs)
46+
[![Javadoc](https://img.shields.io/badge/JavaDoc-Online-green)](https://jacquard.ellenspertus.com/)

doc/FAQ.md

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
2+
# Jacquard FAQ
3+
* [How do I make sure I have the latest version of the Jacquard library?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#how-do-i-make-sure-i-have-the-latest-version-of-the-jacquard-library)
4+
* [What configuration options are there?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#what-configuration-options-are-there)
5+
* [How do I use Checkstyle?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#how-do-i-use-checkstyle)
6+
* [What's PMD? How do I use it?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#whats-pmd-how-do-i-use-it)
7+
* [How do I set test result visibility?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#how-do-i-set-test-result-visibility)
8+
* [Why was the name "Jacquard" chosen?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#why-was-the-name-jacquard-chosen)
9+
10+
## How do I make sure I have the latest version of the Jacquard library?
11+
12+
See [Refreshing the Jacquard library](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8578e267-2bf0-4849-94c0-b066015c1ee3)
13+
or follow these steps in IntelliJ:
14+
15+
1. Click on `Gradle` in the right sidebar.
16+
2. Right-click (or control-click) on the project name (or the elephant icon to its left).
17+
3. Select `Refresh Gradle Dependencies`.
18+
19+
![screenshot](../images/refresh-jar.png)
20+
21+
## What configuration options are there?
22+
There are currently 3 configurable values:
23+
* `timeout` (default: `10_000L`), how many milliseconds to run a test before termination;
24+
a value of `0` means never to timeout
25+
* `javaLevel` (default: 17), the Java language level used for [syntax-based graders](https://jacquard.ellenspertus.com/com/spertus/jacquard/syntaxgrader/package-summary.html)
26+
* `visibility` (default: [`Visibility.VISIBLE`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Visibility.html#VISIBLE)),
27+
the visibility of test results (except for `JUnitTester` results, which are specified differently)
28+
29+
To use the default values, call [`Autograder.init()`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Autograder.html#init())
30+
at the start of your program. Here's how to explicitly set other values:
31+
32+
```java
33+
Autograder.Builder builder = Autograder.Builder.getInstance();
34+
35+
// By default, tests time out in 10,000 ms if they don't complete.
36+
builder.timeout(5000); // set timeout to 5 s
37+
38+
// By default, Java level 17 is used.
39+
builder.javaLevel(11); // use Java level 11
40+
41+
// By default, all tests results are visible.
42+
builder.visibility(Visibility.HIDDEN); // hide test results
43+
builder.build();
44+
```
45+
This can be written more concisely:
46+
```
47+
Autograder.Builder.getInstance()
48+
.timeout(5000)
49+
.javaLevel(11)
50+
.visibility(Visibility.HIDDEN)
51+
.build();
52+
```
53+
54+
See also the [Autograder configuration chapter](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ba36573d-dd4a-493d-8b3d-b06a0181c9ff&start=15) (0:15-2:06) from [Taking a first look at Homework 1](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=ba36573d-dd4a-493d-8b3d-b06a0181c9ff).
55+
56+
## How do I use Checkstyle?
57+
58+
For general usage information, see [Checkstyle website](https://checkstyle.sourceforge.io/),
59+
especially [Checkstyle configuration](https://checkstyle.sourceforge.io/config.html).
60+
61+
Here is how to create a `CheckstyleGrader` in Jacquard:
62+
63+
```java
64+
CheckstyleGrader checkstyleGrader = new CheckstyleGrader(
65+
"config/checkstyle-rules.xml", // path to configuration file
66+
1.0, // penalty per violation
67+
5.0); // maximum penalty/points
68+
```
69+
70+
See also the [`CheckstyleGrader` javadoc](http://jacquard.ellenspertus.com/com/spertus/jacquard/checkstylegrader/CheckstyleGrader.html).
71+
72+
We recommend putting your configuration file in your project's `config/`
73+
directory so it is copied to Gradescope. We also recommend sharing it with
74+
students so they can run checkstyle in their
75+
IDE ([IntelliJ plugin](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea),
76+
[Eclipse plugin](https://checkstyle.org/eclipse-cs/#!/))
77+
before uploading. The IntelliJ plugin supports using a local configuration
78+
file or accessing one via URL, so students don't need to download it
79+
(but will need to configure the plugin to point to it).
80+
81+
For more detail, see
82+
[Jacquard Example 0](https://github.com/jacquard-autograder/jacquard-example0).
83+
84+
## What's PMD? How do I use it?
85+
[PMD](https://pmd.github.io/) (which is not an acronym) is a source code analyzer
86+
capable of more complex checks than Checkstyle, such as whether the `@Override`
87+
annotation is always used where permitted.
88+
89+
PMD rules are organized into rulesets, which, as the name suggests, are sets of rules.
90+
You can [make your own rulesets](https://pmd.github.io/pmd/pmd_userdocs_making_rulesets.htm)
91+
or use [Java rulesets](https://github.com/pmd/pmd/tree/master/pmd-java/src/main/resources)
92+
built in to PMD, such as [`category/java/bestpractices.xml`](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/resources/category/java/bestpractices.xml).
93+
94+
Jacquard's [PMDGrader](https://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html)
95+
has two static factory methods:
96+
* [`createFromRuleSetPaths()`](http://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html#createFromRuleSetPaths(double,double,java.lang.String...)),
97+
which lets you specify one or more rulesets to be used in their entirety [used in [Jacquard Example 0](https://github.com/jacquard-autograder/jacquard-example0)]
98+
* [`createFromRules()`](http://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html#createFromRules(double,double,java.lang.String,java.lang.String,java.lang.String...)),
99+
which lets you specify one ruleset and one or more rules from that ruleset [used in Jacquard Example 2]
100+
101+
There are PMD plugins for [IntelliJ](https://plugins.jetbrains.com/plugin/1137-pmd) and [Eclipse](https://marketplace.eclipse.org/category/free-tagging/pmd).
102+
103+
## How do I set test result visibility?
104+
105+
Gradescope specifies four levels of visibility in [Autograder Specifications](https://gradescope-autograders.readthedocs.io/en/latest/specs/):
106+
107+
* `hidden`: test case will never be shown to students
108+
* `after_due_date`: test case will be shown after the assignment's due date has passed. If late submission is allowed, then test will be shown only after the late due date.
109+
* `after_published`: test case will be shown only when the assignment is explicitly published from the "Review Grades" page
110+
* `visible` (default): test case will always be shown
111+
112+
These is a one-to-one correspondence between these visibility levels and the enumerated type [`Visibility`](http://jacquard.ellenspertus.com/com/spertus/jacquard/common/Visibility.html).
113+
114+
Unless otherwise specified, all test results are immediately `visible` to students.
115+
116+
### `JUnitTester` results
117+
Unit tests run through [`JUnitTester`](https://jacquard.ellenspertus.com/com/spertus/jacquard/junittester/JUnitTester.html) (as
118+
opposed to the cross-tester) must be annotated with [`@GradedTest`](https://jacquard.ellenspertus.com/com/spertus/jacquard/junittester/GradedTest.html). The
119+
attribute `visibility` has the default value [`Visibility.VISIBLE`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Visibility.html#VISIBLE) but
120+
can be set to any other visibility. This code is from [Jacquard Example 0](https://github.com/jacquard-autograder/jacquard-example0):
121+
```java
122+
@Test
123+
@GradedTest(name = "works for empty list", points = 5.0, visibility = Visibility.AFTER_PUBLISHED)
124+
public void iteratorOverEmptyList() {
125+
FavoritesIterator<String> iterator = new FavoritesIterator<>(favoriteHotSauces0);
126+
127+
// No items should be returned.
128+
assertFalse(iterator.hasNext());
129+
assertThrows(NoSuchElementException.class, () -> iterator.next());
130+
}
131+
```
132+
133+
### Other results
134+
The visibility level can be set for all other types of autograder results through the
135+
[initial configuration](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#what-configuration-options-are-there).
136+
137+
The visibility level of a generated [`Result`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Result.html) can be mutated by calling the [`changeVisibility(Visibility visibility)` instance method](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Result.html#changeVisibility(com.spertus.jacquard.common.Visibility)) or [`Result.changeVisibility(List<Result> results, Visibility visibility)`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Result.html#changeVisibility(java.util.List,com.spertus.jacquard.common.Visibility)), as shown:
138+
139+
```java
140+
// Use the default configuration, which includes full visibility.
141+
Autograder.init();
142+
final Target target = Target.fromClass(FavoritesIterator.class);
143+
List<Result> results = new ArrayList();
144+
145+
// Checkstyle results should be fully visible.
146+
CheckstyleGrader checkstyleGrader = new CheckstyleGrader(
147+
"config/checkstyle-rules.xml",
148+
1.0,
149+
5.0);
150+
results.addAll(checkstyleGrader.grade(target));
151+
152+
// PMD results should be visible only after the due date.
153+
PmdGrader pmdGrader = PmdGrader.createFromRules(
154+
1.0,
155+
5.0,
156+
"category/java/bestpractices.xml",
157+
"MissingOverride");
158+
List<Result> pmdResults = pmdGrader.grade(target);
159+
// Change visibility before adding to results.
160+
Result.changeVisibility(pmdResults, Visibility.AFTER_DUE_DATE);
161+
results.addAll(pmdResults);
162+
```
163+
164+
## Why was the name "Jacquard" chosen?
165+
166+
The CSV files used for cross-testing made me think of looms, such as the [looms created by
167+
Joseph Marie Jacquard](https://en.wikipedia.org/wiki/Jacquard_machine), which were
168+
controlled by punched cards so play an important role in computing history. Also, the
169+
starting letters correspond to Java or Java Autograder. Claude.ai suggested
170+
this backronym: _Java Assignment Checking with Quality Unit-testing, Analysis, Reporting, and Diagnostics_.
171+
172+
173+
## Where can I get support?
174+
175+
There are low-volume Google
176+
groups [jacquard-announce](https://groups.google.com/g/jacquard-announce)
177+
and [jacquard-discuss](https://groups.google.com/g/jacquard-discuss).
178+
179+
You can also [create issues](https://github.com/jacquard-autograder/jacquard/issues)
180+
(feature requests and bug reports).
181+
182+
[![Javadoc](https://img.shields.io/badge/JavaDoc-Online-green)](https://jacquard.ellenspertus.com/)

doc/Guide.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Jacquard User Guide
2+
3+
Jacquard-based autograders consist of:
4+
* Java code that makes use of the Jacquard library
5+
* scripts and a configuration file to prepare student submissions to be
6+
used with the Java code
7+
8+
## Examples
9+
10+
For complete examples, see:
11+
12+
* [Jacquard Template 1](https://github.com/espertus/jacquard-template1), which
13+
demonstrates these features, applied to a single submitted file.
14+
* Checkstyle tests
15+
* PMD tests
16+
* Parser-based tests (ensuring that language features are used as required)
17+
* JUnit tests

images/refresh-jar.png

16.6 KB
Loading

images/reload-all-gradle-projects.png

9.03 KB
Loading

images/run-tests.png

6.98 KB
Loading

0 commit comments

Comments
 (0)