Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Nov 22, 2023
1 parent 253b5e5 commit 685e404
Show file tree
Hide file tree
Showing 27 changed files with 614 additions and 734 deletions.
68 changes: 36 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
</properties>

<dependencies>

<dependency>
<groupId>io.github.kit-sdq</groupId>
<artifactId>artemis4j</artifactId>
<version>6.6.6</version>
</dependency>
<dependency>
<groupId>org.jcommander</groupId>
<artifactId>jcommander</artifactId>
<version>1.83</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -36,11 +41,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jcommander</groupId>
<artifactId>jcommander</artifactId>
<version>1.83</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -96,6 +100,33 @@
<ratchetFrom>origin/main</ratchetFrom>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>edu.kit.kastel.sdq.scorestats.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>artemis-score-stats-complete</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>fatjar</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand Down Expand Up @@ -140,33 +171,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>edu.kit.kastel.sdq.scorestats.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>artemis-score-stats-complete</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>fatjar</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
11 changes: 6 additions & 5 deletions src/main/java/edu/kit/kastel/sdq/scorestats/Application.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* Licensed under EPL-2.0 2023. */
package edu.kit.kastel.sdq.scorestats;

import edu.kit.kastel.sdq.scorestats.cli.CLI;

public class Application {
public static void main(String[] args) {
CLI cli = new CLI();
cli.run(args);
}
public final class Application {
public static void main(String[] args) {
CLI cli = new CLI();
cli.run(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@
*/
public class Arguments {

@Parameter(names = { "-host", "-h" }, description = "Artemis host", required = true)
public String host;
@Parameter(names = { "-host", "-h" }, description = "Artemis host", required = true)
public String host;

@Parameter(names = { "-user", "-u" }, description = "Artemis user name", required = true)
public String username;
@Parameter(names = { "-user", "-u" }, description = "Artemis user name", required = true)
public String username;

@Parameter(names = { "-password", "-p" }, description = "Artemis password", password = true, required = true)
public String password;
@Parameter(names = { "-password", "-p" }, description = "Artemis password", password = true, required = true)
public String password;

@Parameter(names = { "-output", "-o" }, description = "The output directory.", converter = FileConverter.class)
public File outDir = new File("./stats");
@Parameter(names = { "-output", "-o" }, description = "The output directory.", converter = FileConverter.class)
public File outDir = new File("./stats");

@Parameter(names = { "-groups",
"-g" }, description = "The directory containing the group files. If no directory is specified, or if the directory is empty, only one report about all submissions will be generated.", converter = FileConverter.class, validateWith = ExistingDirectory.class)
public File groupsDir;
@Parameter(names = { "-groups",
"-g" }, description = "The directory containing the group files. If no directory is specified, or if the directory is empty, only one report about all submissions will be generated.", converter = FileConverter.class, validateWith = ExistingDirectory.class)
public File groupsDir;

@Parameter(names = { "-configs",
"-c" }, description = "The directory containing the grading config files. A config file must contain the short name of its corresponding exercise. For exercises without a config file all stats related to manual assessments will not be generated.", converter = FileConverter.class, validateWith = ExistingDirectory.class)
public File configsDir;
@Parameter(names = { "-configs",
"-c" }, description = "The directory containing the grading config files. A config file must contain the short name of its corresponding exercise. For exercises without a config file all stats related to manual assessments will not be generated.", converter = FileConverter.class, validateWith = ExistingDirectory.class)
public File configsDir;

@Parameter(names = { "-outputLimit",
"-l" }, description = "How many elements should at most be listed. This setting will be respected by all stats where the entirety of the result is not particularly significant.", validateWith = PositiveInteger.class)
public Integer outputLimit;
@Parameter(names = { "-outputLimit",
"-l" }, description = "How many elements should at most be listed. This setting will be respected by all stats where the entirety of the result is not particularly significant.", validateWith = PositiveInteger.class)
public int outputLimit = 0;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* Licensed under EPL-2.0 2023. */
package edu.kit.kastel.sdq.scorestats.config;

import java.io.File;
Expand All @@ -24,62 +25,38 @@

public class ReportBuilder {

private Output output;

public ReportBuilder createReport(
Arguments arguments,
Course course,
Exercise exercise,
ExerciseConfig config,
Assessments<AutomaticFeedbackType> assessments,
Set<String> students) {

Report<AutomaticFeedbackType> report = new Report<>(
course,
exercise,
config,
assessments,
students);

ReportOutput output = new ReportOutput(
arguments,
course,
exercise,
report.accept(new ParticipationReport<>()),
report.count(new FeedbackGroupPassedCount<AutomaticFeedbackType>(
AutomaticFeedbackType.MANDATORY)),
report.average(new ScoreAverage<>()),
report.average(
new FeedbackGroupPassedAverage<AutomaticFeedbackType>(
AutomaticFeedbackType.FUNCTIONAL)),
report.average(
new FeedbackGroupPassedAverage<AutomaticFeedbackType>(
AutomaticFeedbackType.MODELLING_CHECK)),
config == null ? null : report.average(new ManualDeductionAverage<>()),
report.frequency(
new FeedbackGroupFailedFrequency<AutomaticFeedbackType>(
AutomaticFeedbackType.FUNCTIONAL)),
report.frequency(
new FeedbackGroupFailedFrequency<AutomaticFeedbackType>(
AutomaticFeedbackType.MODELLING_CHECK)),
config == null ? null : report.frequency(new MistakeTypeFrequencyPerSubmission<>()),
config == null ? null : report.frequency(new MistakeTypeFrequencyPerAnnotation<>()),
config == null ? null : report.list(new CustomPenaltyAnnotationList<>()));

this.output = output;
return this;
}

public Output getOutput() {
return this.output;
}

public void writeToFile(File file) {
FileWriter writer = new FileWriter(this.output, file);
try {
writer.write();
} catch (IOException e) {
System.err.println("Error, could not write to file: %s".formatted(file.getAbsolutePath()));
}
}
private Output output;

public ReportBuilder createReport(Arguments arguments, Course course, Exercise exercise, ExerciseConfig config,
Assessments<AutomaticFeedbackType> assessments, Set<String> students) {

Report<AutomaticFeedbackType> report = new Report<>(course, exercise, config, assessments, students);

this.output = new ReportOutput(arguments, course, exercise, report.accept(new ParticipationReport<>()),
report.count(new FeedbackGroupPassedCount<AutomaticFeedbackType>(AutomaticFeedbackType.MANDATORY)), report.average(new ScoreAverage<>()),
report.average(new FeedbackGroupPassedAverage<AutomaticFeedbackType>(AutomaticFeedbackType.FUNCTIONAL)),
report.average(new FeedbackGroupPassedAverage<AutomaticFeedbackType>(AutomaticFeedbackType.MODELLING_CHECK)),
config == null ? null : report.average(new ManualDeductionAverage<>()),

report.frequency(new FeedbackGroupFailedFrequency<AutomaticFeedbackType>(AutomaticFeedbackType.MANDATORY)),
report.frequency(new FeedbackGroupFailedFrequency<AutomaticFeedbackType>(AutomaticFeedbackType.FUNCTIONAL)),
report.frequency(new FeedbackGroupFailedFrequency<AutomaticFeedbackType>(AutomaticFeedbackType.MODELLING_CHECK)),
config == null ? null : report.frequency(new MistakeTypeFrequencyPerSubmission<>()),
config == null ? null : report.frequency(new MistakeTypeFrequencyPerAnnotation<>()),
config == null ? null : report.list(new CustomPenaltyAnnotationList<>()));
return this;
}

public Output getOutput() {
return this.output;
}

public void writeToFile(File file) {
FileWriter writer = new FileWriter(this.output, file);
try {
writer.write();
} catch (IOException e) {
System.err.printf("Error, could not write to file: %s%n", file.getAbsolutePath());
}
}
}
Loading

0 comments on commit 685e404

Please sign in to comment.