Skip to content

Commit

Permalink
Merge pull request #122 from Jesse-longname/stage-3-prep
Browse files Browse the repository at this point in the history
Modify results to show more information.
  • Loading branch information
Jesse-longname authored Apr 12, 2019
2 parents 1b653ca + 90e39fc commit 002a038
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*ngFor="let match of result.matches; let j = index"
>
<div class="result__header" (click)="toggleMatch(j)">
Match {{ j + 1 }}
<span>Match {{ j + 1 }}</span> <span>{{match.maxPercentage}}% Matching</span> <span>{{ match.lines.length }} Matching Files</span>
</div>
<div class="result__match--container" [class.hidden]="!toggles[j]">
<div class="result__match--left result__match--box" (click)="toggleLeftNames(j)">
Expand All @@ -24,7 +24,7 @@
class="result__names-list"
*ngFor="let name of match.lines; let x = index"
>
<div class="result__name" *ngIf="x !== leftChoices[j]" (click)="updateLeftChoice(j,x)">
<div class="result__name" *ngIf="x !== leftChoices[j] && x !== rightChoices[j]" (click)="updateLeftChoice(j,x)">
{{ name.submission.studentFirstname }}
{{ name.submission.studentLastname }}-{{
name.submission.studentNumber
Expand Down Expand Up @@ -59,7 +59,7 @@
class="result__names-list"
*ngFor="let name of match.lines; let x = index"
>
<div class="result__name" *ngIf="x !== rightChoices[j]" (click)="updateRightChoice(j,x)">
<div class="result__name" *ngIf="x !== rightChoices[j] && x !== leftChoices[j]" (click)="updateRightChoice(j,x)">
{{ name.submission.studentFirstname }}
{{ name.submission.studentLastname }}-{{
name.submission.studentNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
padding-left: 25px;
font-weight: bold;
border-bottom: solid 1px gray;

display: flex;
justify-content: space-between;
padding-right: 25px;

&:hover {
background-color: whitesmoke;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,38 @@ export class ResultComponent implements OnInit {
this.leftToggles.fill(false);
this.rightToggles.fill(false);
for (let i = 0; i < this.result.matches.length; i++) {
this.result.matches[i].maxPercentage = "0";
for (let j = 0; j < this.result.matches[i].lines.length; j++) {
const path = this.result.matches[i].lines[j].filePath;
this.result.matches[i].lines[j].viewFile = this.result.files.find(
let line = this.result.matches[i].lines[j];
line.viewFile = this.result.files.find(
f => f.filePath === path
);
// Find out how much of the file this match is
line.percentage = (((line.lineEnd - line.lineStart) / line.viewFile.lines.length)*100).toFixed(0);
// Save the highest percentage into the match
if (parseInt(line.percentage) > parseInt(this.result.matches[i].maxPercentage)) {
this.result.matches[i].maxPercentage = line.percentage;
}

// Try and fix test naming, so that the TA doesn't get confused by
// the file name
// TODO: Remove after Stage 3 is done
if (line.submission.studentFirstname.includes("ThisIsTestData")) {
line.submission.studentFirstname = "";
line.submission.studentLastname = "Folder";
line.submission.studentNumber = line.submission.studentNumber.replace(this.result.assignmentName, "");
while (line.submission.studentNumber.includes("&underscore&")) {
line.submission.studentNumber = line.submission.studentNumber.replace("&underscore&", "_");
}

}
}
}
this.result.matches.sort((a,b) => {
return parseInt(b.maxPercentage) - parseInt(a.maxPercentage);
})

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ export class Line {
match: Match;
submission: Submission;
viewFile: File;
percentage: string;
}

export class Match {
matchId: number;
resultId: number;
lines: Line[];
maxPercentage: string;
}

export class Result {
Expand Down
7 changes: 6 additions & 1 deletion hook_system/client/ClientServer/Services/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@ public async Task<FileResult> ReadFileFromStorageAsync(long submissionId, string
{
var splitPaths = lineFilePath.Split(Path.DirectorySeparatorChar);
var str = splitPaths.Last();
var filename = str.Substring(str.IndexOf('-') + 1);
Console.WriteLine(str);
var filename = str;
// Handle scrubbed data
if (filename.StartsWith("Scrubbed-")) {
filename = filename.Substring(filename.IndexOf('-') + 1);
}
var path = Path.Join("Temp", submissionFilePath, filename);

var lines = await System.IO.File.ReadAllLinesAsync(path);
Expand Down

0 comments on commit 002a038

Please sign in to comment.