Skip to content

Commit

Permalink
Merge branch 'main' into fix-ontime-submission-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
19mdavenport authored Nov 26, 2024
2 parents 040af87 + 16eec28 commit 5a75812
Show file tree
Hide file tree
Showing 7 changed files with 453 additions and 159 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>edu.byu.cs.server.Server</mainClass>
<mainClass>Main</mainClass>
</transformer>
</transformers>
</configuration>
Expand All @@ -169,7 +169,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>edu.byu.cs.server.Server</mainClass>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import edu.byu.cs.autograder.GradingException;
import edu.byu.cs.server.endpointprovider.EndpointProvider;
import edu.byu.cs.server.endpointprovider.EndpointProviderImpl;
import edu.byu.cs.dataAccess.DaoService;
import edu.byu.cs.dataAccess.DataAccessException;
import edu.byu.cs.properties.ApplicationProperties;
import edu.byu.cs.server.Server;
import edu.byu.cs.service.SubmissionService;
import edu.byu.cs.util.ResourceUtils;
import org.apache.commons.cli.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

public class Main {
private static Logger LOGGER = LoggerFactory.getLogger(Main.class);

private static EndpointProvider endpointProvider = new EndpointProviderImpl();

public static void main(String[] args) {
ResourceUtils.copyResourceFiles("phases", new File(""));
setupProperties(args);

try {
DaoService.initializeSqlDAOs();
} catch (DataAccessException e) {
LOGGER.error("Error setting up database", e);
throw new RuntimeException(e);
}

new Server(endpointProvider).start(8080);

try {
SubmissionService.reRunSubmissionsInQueue();
} catch (IOException | DataAccessException | GradingException e) {
LOGGER.error("Error rerunning submissions already in queue", e);
}
}

private static void setupProperties(String[] args) {
Options options = getOptions();

Properties properties = new Properties();

CommandLineParser parser = new DefaultParser();
try {
CommandLine cmd = parser.parse(options, args);
if (cmd.hasOption("db-host")) {
properties.setProperty("db-host", cmd.getOptionValue("db-host"));
}
if (cmd.hasOption("db-port")) {
properties.setProperty("db-port", cmd.getOptionValue("db-port"));
}
if (cmd.hasOption("db-name")) {
properties.setProperty("db-name", cmd.getOptionValue("db-name"));
}
if (cmd.hasOption("db-user")) {
properties.setProperty("db-user", cmd.getOptionValue("db-user"));
}
if (cmd.hasOption("db-pass")) {
properties.setProperty("db-pass", cmd.getOptionValue("db-pass"));
}
if (cmd.hasOption("frontend-url")) {
properties.setProperty("frontend-url", cmd.getOptionValue("frontend-url"));
}
if (cmd.hasOption("cas-callback-url")) {
properties.setProperty("cas-callback-url", cmd.getOptionValue("cas-callback-url"));
}
if (cmd.hasOption("canvas-token")) {
properties.setProperty("canvas-token", cmd.getOptionValue("canvas-token"));
}
if (cmd.hasOption("use-canvas")) {
properties.setProperty("use-canvas", cmd.getOptionValue("use-canvas"));
}
if (cmd.hasOption("disable-compilation")) {
properties.setProperty("run-compilation", "false");
}
} catch (ParseException e) {
throw new RuntimeException("Error parsing command line arguments", e);
}

ApplicationProperties.loadProperties(properties);
}

private static Options getOptions() {
Options options = new Options();
options.addOption(null, "db-host", true, "Database Host");
options.addOption(null, "db-port", true, "Database Port");
options.addOption(null, "db-name", true, "Database Name");
options.addOption(null, "db-user", true, "Database User");
options.addOption(null, "db-pass", true, "Database Password");
options.addOption(null, "frontend-url", true, "Frontend URL");
options.addOption(null, "cas-callback-url", true, "CAS Callback URL");
options.addOption(null, "canvas-token", true, "Canvas Token");
options.addOption(null, "use-canvas", true, "Using Canvas");
options.addOption(null, "disable-compilation", false, "Turn off student code compilation");
return options;
}

}
8 changes: 5 additions & 3 deletions src/main/java/edu/byu/cs/autograder/score/Scorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,11 @@ private Rubric.Results mergeResultsWithPrevious(Rubric.RubricType rubricType, Ru
float score = startingScore;

for (Submission previousSubmission : previousSubmissions) {
Rubric.RubricItem previousItem = previousSubmission.rubric().items().get(rubricType);
if (previousItem != null && previousItem.results().rawScore() <= results.rawScore()) {
score = Math.max(score, previousItem.results().score());
if(previousSubmission.passed()) {
Rubric.RubricItem previousItem = previousSubmission.rubric().items().get(rubricType);
if (previousItem != null && previousItem.results().rawScore() <= results.rawScore()) {
score = Math.max(score, previousItem.results().score());
}
}
}

Expand Down
Loading

0 comments on commit 5a75812

Please sign in to comment.