|
10 | 10 |
|
11 | 11 | import java.io.File; |
12 | 12 | import java.io.IOException; |
| 13 | +import java.nio.file.Files; |
| 14 | +import java.nio.file.Path; |
13 | 15 | import java.util.*; |
14 | 16 |
|
| 17 | +/** |
| 18 | + * The practical demonstration stage differs from the Functionality stage |
| 19 | + * in that test classes are read from a tasks file included in the submission |
| 20 | + * as each student will have a different subset of test classes. |
| 21 | + */ |
| 22 | +// TODO: This should really share as much of Functionality as possible |
15 | 23 | public class PracDemo implements Stage { |
16 | 24 |
|
17 | | - public final static String name = "Functionality"; |
| 25 | + public final static String name = "PracDemo"; |
18 | 26 |
|
19 | 27 | private final double maxScore; |
20 | 28 | private final boolean showPassing; |
@@ -104,10 +112,16 @@ public StageResult run(Submission submission, Solution solution) throws StageExc |
104 | 112 | var totalNumTests = 0; |
105 | 113 | var innerResults = new ArrayList<Result>(); |
106 | 114 | var classResults = new ArrayList<ClassResult>(); |
107 | | - for (String className : tests) { |
108 | | - if (!className.endsWith("Test")) { |
109 | | - continue; |
110 | | - } |
| 115 | + |
| 116 | + List<String> testNames; |
| 117 | + try { |
| 118 | + Path taskFile = Path.of(submission.getBasePath() + "/tasks"); |
| 119 | + testNames = Files.readAllLines(taskFile); |
| 120 | + } catch (IOException e) { |
| 121 | + throw new StageException("Unable to find tasks file"); |
| 122 | + } |
| 123 | + for (String className : testNames) { |
| 124 | + className = "demos." + className + "Test"; |
111 | 125 |
|
112 | 126 | int classPassing = 0; |
113 | 127 |
|
@@ -171,9 +185,10 @@ public StageResult run(Submission submission, Solution solution) throws StageExc |
171 | 185 | } |
172 | 186 | double scaled = Math.ceil((total / possible) * maxScore); |
173 | 187 |
|
174 | | - var equation = "\n$$\n\\dfrac{" + String.format("%.3f", total) + "}{" + possible + "} \\times " + maxScore + " = " + scaled + "\n$$"; |
| 188 | + //var equation = "\n$$\n\\dfrac{" + String.format("%.3f", total) + "}{" + possible + "} \\times " + maxScore + " = " + scaled + "\n$$"; |
| 189 | + var equation = "\n$$sum = "+total+"$$"; |
175 | 190 | var overview = new Result(name); |
176 | | - overview.setScore(scaled) |
| 191 | + overview.setScore(total) |
177 | 192 | .setMaxScore(maxScore) |
178 | 193 | .appendOutput(table + equation) |
179 | 194 | .setOutputFormat("md") |
|
0 commit comments