Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable canvas and compilation #369

Merged
merged 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
frozenfrank marked this conversation as resolved.
Show resolved Hide resolved
} 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