Skip to content

Commit 3fd52c1

Browse files
committed
Add Q&A from Example 2
1 parent 038a8ea commit 3fd52c1

File tree

1 file changed

+105
-37
lines changed

1 file changed

+105
-37
lines changed

doc/FAQ.md

+105-37
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
* [How do I use Checkstyle?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#how-do-i-use-checkstyle)
66
* [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)
77
* [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+
* [How is code coverage measured?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#how-is-code-coverage-measured)
9+
* [What is cross-testing?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#what-is-cross-testing)
810
* [Why was the name "Jacquard" chosen?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#why-was-the-name-jacquard-chosen)
11+
* [Where can I view the Javadoc?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#where-can-i-view-the-javadoc)
12+
* [Where can I get support?](https://github.com/jacquard-autograder/jacquard-examples/blob/main/README.md#where-can-i-get-support)
13+
914

1015
## How do I make sure I have the latest version of the Jacquard library?
1116

@@ -51,7 +56,7 @@ Autograder.Builder.getInstance()
5156
.build();
5257
```
5358

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).
59+
See also the [Autograder configuration chapter](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=6b00de8f-4abe-49a6-a348-b12e0012f37b&start=15) (0:15-2:06) from [Example 2.1: Going through a more complicated AutograderMain](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=6b00de8f-4abe-49a6-a348-b12e0012f37b).
5560

5661
## How do I use Checkstyle?
5762

@@ -67,7 +72,7 @@ CheckstyleGrader checkstyleGrader = new CheckstyleGrader(
6772
5.0); // maximum penalty/points
6873
```
6974

70-
See also the [`CheckstyleGrader` javadoc](http://jacquard.ellenspertus.com/com/spertus/jacquard/checkstylegrader/CheckstyleGrader.html).
75+
See also the [`CheckstyleGrader` javadoc](https://jacquard.ellenspertus.com/com/spertus/jacquard/checkstylegrader/CheckstyleGrader.html).
7176

7277
We recommend putting your configuration file in your project's `config/`
7378
directory so it is copied to Gradescope. We also recommend sharing it with
@@ -93,10 +98,10 @@ built in to PMD, such as [`category/java/bestpractices.xml`](https://github.com/
9398

9499
Jacquard's [PMDGrader](https://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html)
95100
has two static factory methods:
96-
* [`createFromRuleSetPaths()`](http://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html#createFromRuleSetPaths(double,double,java.lang.String...)),
101+
* [`createFromRuleSetPaths()`](https://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html#createFromRuleSetPaths(double,double,java.lang.String...)),
97102
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]
103+
* [`createFromRules()`](https://jacquard.ellenspertus.com/com/spertus/jacquard/pmdgrader/PmdGrader.html#createFromRules(double,double,java.lang.String,java.lang.String,java.lang.String...)),
104+
which lets you specify one ruleset and one or more rules from that ruleset [used in [Jacquard Example 2](https://github.com/jacquard-autograder/jacquard-example2)]
100105

101106
There are PMD plugins for [IntelliJ](https://plugins.jetbrains.com/plugin/1137-pmd) and [Eclipse](https://marketplace.eclipse.org/category/free-tagging/pmd).
102107

@@ -119,15 +124,15 @@ opposed to the cross-tester) must be annotated with [`@GradedTest`](https://jacq
119124
attribute `visibility` has the default value [`Visibility.VISIBLE`](https://jacquard.ellenspertus.com/com/spertus/jacquard/common/Visibility.html#VISIBLE) but
120125
can be set to any other visibility. This code is from [Jacquard Example 0](https://github.com/jacquard-autograder/jacquard-example0):
121126
```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-
}
127+
@Test
128+
@GradedTest(name = "works for empty list", points = 5.0, visibility = Visibility.AFTER_PUBLISHED)
129+
public void iteratorOverEmptyList() {
130+
FavoritesIterator<String> iterator = new FavoritesIterator<>(favoriteHotSauces0);
131+
132+
// No items should be returned.
133+
assertFalse(iterator.hasNext());
134+
assertThrows(NoSuchElementException.class, () -> iterator.next());
135+
}
131136
```
132137

133138
### Other results
@@ -137,38 +142,101 @@ The visibility level can be set for all other types of autograder results throug
137142
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:
138143

139144
```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);
145+
// Use the default configuration, which includes full visibility.
146+
Autograder.init();
147+
final Target target = Target.fromClass(FavoritesIterator.class);
148+
List<Result> results = new ArrayList();
149+
150+
// PMD results should be visible only after the due date.
151+
PmdGrader pmdGrader = PmdGrader.createFromRules(
152+
1.0,
153+
5.0,
154+
"category/java/bestpractices.xml",
155+
"MissingOverride");
156+
List<Result> pmdResults = pmdGrader.grade(target);
157+
// Change visibility before adding to results.
158+
Result.changeVisibility(pmdResults, Visibility.AFTER_DUE_DATE);
159+
results.addAll(pmdResults);
160+
```
161+
162+
## How is code coverage measured?
163+
164+
Code coverage is measured using [JaCoCo](https://www.jacoco.org/jacoco/index.html). We recommend
165+
having students run JaCoCo inside IntelliJ or Eclipse, because the plugins show which lines of
166+
code are exercised by the tests.
167+
168+
When creating a [`CodeCoverageTester`](https://jacquard.ellenspertus.com/com/spertus/jacquard/coverage/CodeCoverageTester.html),
169+
a [`Scorer`](https://jacquard.ellenspertus.com/com/spertus/jacquard/coverage/Scorer.html) must be
170+
provided to convert the line and branch coverage percentages into points. The concrete scorers are
171+
provided:
172+
* [`LinearScorer`](https://jacquard.ellenspertus.com/com/spertus/jacquard/coverage/LinearScorer.html),
173+
which uses a linear function of the line and branch coverage percentages
174+
* [`LinearBranchScorer`](https://jacquard.ellenspertus.com/com/spertus/jacquard/coverage/LinearBranchScorer.html),
175+
which uses a linear function of the branch coverage percentage (ignoring line coverage)
176+
* [`LinearLineScorer`](https://jacquard.ellenspertus.com/com/spertus/jacquard/coverage/LinearLineScorer.html),
177+
which uses a linear function of the line coverage percentage (ignoring branch coverage)
178+
If you want to write your own scorer, we suggest viewing [`LinearScorer.java`](https://github.com/jacquard-autograder/jacquard/blob/main/src/main/java/com/spertus/jacquard/coverage/LinearScorer.java).
179+
180+
## What is cross-testing?
181+
Cross-testing is my term for running multiple sets of tests against multiple implementations.
182+
Most autograders only run instructor tests against student code. Jacquard also supports running
183+
student tests against multiple versions of instructor code.
184+
185+
Cross-testing using submitted code is specified by a CSV file, such as
186+
[Example 2's `student-tests.csv`](https://github.com/jacquard-autograder/jacquard-example2/blob/main/src/main/resources/student-tests.csv):
187+
188+
| | student | correct | buggy |
189+
|---: | :--: | :--: | :--: |
190+
| size | 10 | 5 | -5 |
191+
| concat | 20 | 10 | -10 |
192+
193+
The header and first row mean:
194+
* If the tests do not report any errors on the implementation of the `size()` method in the `student` package, 10 points are earned.
195+
* If the tests do not report any errors on the implementation of the `size()` method in the `correct` package, 5 points are earned.
196+
* If the tests do report an errors on the implementation of the `size()` method in the `buggy` package, 5 points are earned.
197+
198+
The negative signs in the "buggy" column indicate that the tests are inverted (i.e., points are earned if they fail).
199+
200+
Test names must start with the name of the method under test, such as "sizeWorksForEmptyList()".
201+
202+
This excerpt from [Example 2's `main()` method](https://github.com/jacquard-autograder/jacquard-example2/blob/main/src/main/java/student/AutograderMain.java#L79)
203+
shows how the cross-tester is created and run:
204+
```java
205+
// Create CrossTester to run student tests on:
206+
// * student code (20 points)
207+
// * hidden correct implementation (15 points)
208+
// * hidden buggy implementation (15 points)
209+
// Grading detail is in student-tests.csv.
210+
CrossTester crossTester = new CrossTester(
211+
student.ILOSTest.class, // the test to run
212+
"student-tests.csv" // the name of the CSV file
213+
);
214+
results.addAll(crossTester.run());
162215
```
163216

217+
See also the [Example 2 cross-tester video](https://northeastern.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=165ca9fa-98eb-4f0f-8841-b069013430c5).
218+
164219
## Why was the name "Jacquard" chosen?
165220

166221
The CSV files used for cross-testing made me think of looms, such as the [looms created by
167222
Joseph Marie Jacquard](https://en.wikipedia.org/wiki/Jacquard_machine), which were
168223
controlled by punched cards so play an important role in computing history. Also, the
169224
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_.
225+
this backronym:
226+
227+
* **J**ava
228+
* **A**ssignment
229+
* **C**hecking with
230+
* **Q**uality
231+
* **U**nit-testing,
232+
* **A**nalysis,
233+
* **R**eporting, and
234+
* **D**iagnostics
235+
236+
## Where can I view the Javadoc?
171237

238+
The Javadoc is available at [https://jacquard.ellenspertus.com/](https://jacquard.ellenspertus.com/).
239+
There are also linked badges at the bottom of Markdown pages, such as this one.
172240

173241
## Where can I get support?
174242

0 commit comments

Comments
 (0)