Skip to content

Commit

Permalink
Merge pull request #369 from softwareconstruction240/disable-canvas-a…
Browse files Browse the repository at this point in the history
…nd-compilation

Disable canvas and compilation
  • Loading branch information
frozenfrank authored May 11, 2024
2 parents 7348f20 + 2cb576e commit 01b0e93
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
"--cas-callback-url", "changeme",
"--canvas-token", "changeme",
"--use-canvas", "true",
# "--disable-compilation", # Enable me, if desired!
]
networks:
- autograder
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/byu/cs/autograder/Grader.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import edu.byu.cs.dataAccess.DataAccessException;
import edu.byu.cs.model.*;
import edu.byu.cs.dataAccess.DaoService;
import edu.byu.cs.properties.ApplicationProperties;
import edu.byu.cs.util.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -31,7 +32,7 @@ public class Grader implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Grader.class);

/** DEV ONLY. Default: true. Skips compilation and evaluation of student projects. */
private static final boolean RUN_COMPILATION = true;
private final boolean RUN_COMPILATION = ApplicationProperties.runCompilation();

private final DatabaseHelper dbHelper;

Expand Down Expand Up @@ -87,7 +88,7 @@ public void run() {
dbHelper.setUp();
if (RUN_COMPILATION) compileHelper.compile();

new PreviousPhasePassoffTestGrader(gradingContext).runTests();
if (RUN_COMPILATION) new PreviousPhasePassoffTestGrader(gradingContext).runTests();

RubricConfig rubricConfig = DaoService.getRubricConfigDao().getRubricConfig(gradingContext.phase());
var evaluationResults = evaluateProject(RUN_COMPILATION ? rubricConfig : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.byu.cs.dataAccess.DaoService;
import edu.byu.cs.dataAccess.DataAccessException;
import edu.byu.cs.model.Phase;
import edu.byu.cs.properties.ApplicationProperties;
import edu.byu.cs.util.PhaseUtils;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
Expand Down Expand Up @@ -41,8 +42,9 @@ public LateDayCalculator() {
}

public int calculateLateDays(Phase phase, String netId) throws GradingException, DataAccessException {
int assignmentNum = PhaseUtils.getPhaseAssignmentNumber(phase);
if (!ApplicationProperties.useCanvas()) return 0;

int assignmentNum = PhaseUtils.getPhaseAssignmentNumber(phase);
int canvasUserId = DaoService.getUserDao().getUser(netId).canvasUserId();

ZonedDateTime dueDate;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/edu/byu/cs/autograder/score/Scorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import edu.byu.cs.canvas.model.CanvasSubmission;
import edu.byu.cs.dataAccess.*;
import edu.byu.cs.model.*;
import edu.byu.cs.properties.ApplicationProperties;
import edu.byu.cs.util.PhaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -79,6 +80,12 @@ private Submission attemptSendToCanvas(
Rubric rubric, CommitVerificationResult commitVerificationResult,
int daysLate, float thisScore
) throws DataAccessException, GradingException {

if (!ApplicationProperties.useCanvas()) {
return saveResults(rubric, commitVerificationResult, daysLate, thisScore,
"Would have attempted grade-book submission, but skipped due to application properties.");
}

int canvasUserId = getCanvasUserId();
int assignmentNum = PhaseUtils.getPhaseAssignmentNumber(gradingContext.phase());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ public static String canvasAPIToken() {
public static boolean useCanvas() {
return Boolean.parseBoolean(get("use-canvas", "true"));
}

public static boolean runCompilation() {
return Boolean.parseBoolean(get("run-compilation", "true"));
}
}
4 changes: 4 additions & 0 deletions src/main/java/edu/byu/cs/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ private static void setupProperties(String[] args) {
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);
}
Expand All @@ -169,6 +172,7 @@ private static Options getOptions() {
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;
}

Expand Down

0 comments on commit 01b0e93

Please sign in to comment.