-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 430-fullstack-enhance…
…-late-penalty-applied-presentation-experience
- Loading branch information
Showing
30 changed files
with
724 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
import edu.byu.cs.properties.ApplicationProperties; | ||
import edu.byu.cs.util.FileUtils; | ||
import edu.byu.cs.util.PhaseUtils; | ||
import edu.byu.cs.util.RepoUrlValidator; | ||
import org.eclipse.jgit.annotations.Nullable; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -59,15 +61,15 @@ public class Grader implements Runnable { | |
public Grader(String repoUrl, String netId, GradingObserver observer, Phase phase, boolean admin) throws IOException, GradingException { | ||
// Init files | ||
if (!admin) { | ||
repoUrl = cleanRepoUrl(repoUrl); | ||
repoUrl = RepoUrlValidator.clean(repoUrl); | ||
} | ||
String phasesPath = new File("./phases").getCanonicalPath(); | ||
long salt = Instant.now().getEpochSecond(); | ||
String stagePath = new File("./tmp-" + repoUrl.hashCode() + "-" + salt).getCanonicalPath(); | ||
File stageRepo = new File(stagePath, "repo"); | ||
|
||
// Init Grading Context | ||
CommitVerificationConfig cvConfig = PhaseUtils.requiresTAPassoffForCommits(phase) ? | ||
CommitVerificationConfig cvConfig = PhaseUtils.shouldVerifyCommits(phase) ? | ||
PhaseUtils.verificationConfig(phase) : null; | ||
this.observer = observer; | ||
this.gradingContext = new GradingContext( | ||
|
@@ -94,7 +96,7 @@ public void run() { | |
} | ||
|
||
RubricConfig rubricConfig = DaoService.getRubricConfigDao().getRubricConfig(gradingContext.phase()); | ||
Rubric rubric = evaluateProject(RUN_COMPILATION ? rubricConfig : null); | ||
Rubric rubric = evaluateProject(RUN_COMPILATION ? rubricConfig : null, commitVerificationResult); | ||
|
||
Submission submission = new Scorer(gradingContext).score(rubric, commitVerificationResult); | ||
DaoService.getSubmissionDao().insertSubmission(submission); | ||
|
@@ -111,7 +113,7 @@ public void run() { | |
} | ||
} | ||
|
||
private Rubric evaluateProject(RubricConfig rubricConfig) throws GradingException, DataAccessException { | ||
private Rubric evaluateProject(RubricConfig rubricConfig, CommitVerificationResult commitVerificationResult) throws GradingException, DataAccessException { | ||
EnumMap<Rubric.RubricType, Rubric.RubricItem> rubricItems = new EnumMap<>(Rubric.RubricType.class); | ||
if (rubricConfig == null) { | ||
return new Rubric(new EnumMap<>(Rubric.RubricType.class), false, "No Rubric Config"); | ||
|
@@ -124,7 +126,7 @@ private Rubric evaluateProject(RubricConfig rubricConfig) throws GradingExceptio | |
case PASSOFF_TESTS -> new PassoffTestGrader(gradingContext).runTests(); | ||
case UNIT_TESTS -> new UnitTestGrader(gradingContext).runTests(); | ||
case QUALITY -> new QualityGrader(gradingContext).runQualityChecks(); | ||
case GITHUB_REPO -> new GitHubAssignmentGrader().grade(); | ||
case GITHUB_REPO -> new GitHubAssignmentGrader().grade(commitVerificationResult); | ||
case GIT_COMMITS, GRADING_ISSUE -> null; | ||
}; | ||
if (results != null) { | ||
|
@@ -136,36 +138,6 @@ private Rubric evaluateProject(RubricConfig rubricConfig) throws GradingExceptio | |
return new Rubric(rubricItems, false, ""); | ||
} | ||
|
||
/** | ||
* Cleans the student's by removing trailing characters after the repo name, | ||
* unless it ends in `.git`. | ||
* | ||
* @param repoUrl The student's repository URL. | ||
* @return Cleaned URL with everything after the repo name stripped off. | ||
* @throws GradingException Throws IOException if repoUrl does not follow expected format | ||
*/ | ||
public static String cleanRepoUrl(String repoUrl) throws GradingException { | ||
String[] regexPatterns = { | ||
"https?://github\\.com/([^/?]+)/([^/?]+)", // https | ||
"[email protected]:([^/]+)/([^/]+).git" // ssh | ||
}; | ||
Pattern pattern; | ||
Matcher matcher; | ||
String githubUsername; | ||
String repositoryName; | ||
for (String regexPattern: regexPatterns) { | ||
pattern = Pattern.compile(regexPattern); | ||
matcher = pattern.matcher(repoUrl); | ||
if (matcher.find()) { | ||
githubUsername = matcher.group(1); | ||
repositoryName = matcher.group(2); | ||
return String.format("https://github.com/%s/%s", githubUsername, repositoryName); | ||
} | ||
} | ||
throw new GradingException("Could not find github username and repository name given '" + repoUrl + "'."); | ||
} | ||
|
||
|
||
private void handleException(GradingException ge, CommitVerificationResult cvr) { | ||
if(cvr == null) { | ||
observer.notifyError(ge.getMessage()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../byu/cs/autograder/TrafficController.java → .../byu/cs/controller/TrafficController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.