Skip to content

Commit

Permalink
Merge branch 'master' into sibinh/maintenance_mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
sibinhho99 authored Aug 13, 2022
2 parents b43da7e + ada8bcf commit 68609bc
Show file tree
Hide file tree
Showing 59 changed files with 1,014 additions and 131 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
loofah (2.9.1)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
Expand All @@ -114,17 +114,17 @@ GEM
msgpack (1.4.2)
mysql2 (0.5.3)
nio4r (2.5.8)
nokogiri (1.13.4)
nokogiri (1.13.6)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
popper_js (2.9.3)
public_suffix (4.0.6)
puma (4.3.12)
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack (2.2.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.7)
Expand All @@ -145,7 +145,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (6.0.3.7)
actionpack (= 6.0.3.7)
Expand Down Expand Up @@ -182,7 +182,7 @@ GEM
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.9)
tzinfo (1.2.10)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Student Submission Integrity Diagnosis (SSID) is a Ruby on Rails web application suite for managing courses, assignments, staff, teaching assistants, students, and student code submissions and most importantly, to **detect and visualize plagiarism** among student code submissions.

SSID works with lexers based on [ANTLR4 Grammars](https://github.com/antlr/grammars-v4) so if you can find / write a grammar for it, SSID can detect and visualize plagiarism for it (scroll down and click on the guide on "Adding support for new language in SSID" to learn the steps needed to add a new grammar). SSID uses the [JavaScript InfoVis Toolkit](http://philogb.github.com/jit/) for its plagiarism visualization. Code display and syntax highlighting is handled by [google-code-prettify](http://code.google.com/p/google-code-prettify/).
SSID works with lexers based on [ANTLR4 Grammars](https://github.com/antlr/grammars-v4) so if you can find / write a grammar for it, SSID can detect and visualize plagiarism for it (scroll down and click on the guide on "Adding support for new language in SSID" to learn the steps needed to add a new grammar). SSID uses the [JavaScript InfoVis Toolkit](http://philogb.github.com/jit/) for its plagiarism visualization. Code display and syntax highlighting is handled by [google-code-prettify](http://code.google.com/p/google-code-prettify/). The file upload preview feature makes use of [JSZip](https://github.com/Stuk/jszip).

## Table Of Contents

Expand Down
3 changes: 2 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
//= link_directory ../stylesheets .css
//= link_directory ../javascripts .js
//= link explorer_canvas/excanvas.compiled.js
//= link jit/jit-yc.js
//= link jit/jit-yc.js
//= link jszip/jszip.min.js
1 change: 1 addition & 0 deletions app/assets/images/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions app/assets/javascripts/assignments_file_upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
This file is part of SSID.
SSID is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SSID is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SSID. If not, see <http://www.gnu.org/licenses/>.
*/

(function () {
window.Assignment || (window.Assignment = {});

Assignment.onLoad = function () {
return $(function () {
$("#assignment_file").on("change", function () {
Assignment.onAssignmentFileInputChange(this);
});
$("#assignment_mapfile").on("change", function () {
Assignment.onAssignmentMapFileInputChange(this);
});
});
}

Assignment.onAssignmentFileInputChange = function (fileInput) {
if (fileInput.files[0] == undefined) {
return;
}
let reader = new FileReader();
reader.onload = (ev) => {
JSZip.loadAsync(ev.target.result)
.then(function (zip) {
var zipObjectNames = Object.keys(zip.files);
var fileNames = zipObjectNames.filter(
(x) => x.charAt(x.length - 1) != "/"
);

// Reset existing file list
$("#student_submissions_zip_files_list").empty();

// Set label of the file list
if (fileNames.length > 10) {
$("#student_submissions_zip_files_list_label").text("Files inside (showing first 10):");
} else if (fileNames.length == 0) {
$("#student_submissions_zip_files_list_label").text("The zip file is empty.");
} else {
$("#student_submissions_zip_files_list_label").text("Files inside:");
}

// Display the first ten files
for (let i = 0; i < Math.min(10, fileNames.length); i++) {
let fileName = fileNames[i];
$("#student_submissions_zip_files_list").append(
"<li><a href=# id=preview_file_" + i + ">" + fileName + "</a></li>"
);

let handleClick = function () {
zip
.file(fileName)
.async("string")
.then((fileContent) => {
Assignment.previewRawFile(fileName, fileContent);
return false;
});
};

$("#preview_file_" + i).click(handleClick);
}

// Indicate that there are more files if there are > 10 files
if (fileNames.length > 10) {
$("#student_submissions_zip_files_list").append("<li>...</li>");
}
})
.catch((err) => {
console.error("Error trying to unzip and process", filename);
console.error(err);
});
};
reader.onerror = (err) => {
console.error("Error trying to read file", err);
};
reader.readAsArrayBuffer(fileInput.files[0]);
}

Assignment.onAssignmentMapFileInputChange = function (fileInput) {
if (fileInput.files[0] == undefined) {
return;
}

let fileName = fileInput.files[0].name;
let reader = new FileReader();

// Reset existing file list
$("#map_files_list").empty();

// Show newly chosen file
$("#map_files_list").prepend("<br>");

$("#map_files_list").append(
"<li><a href=# id=preview_map_file>" + fileName + "</a></li>"
);

reader.readAsText(fileInput.files[0]);

reader.onerror = (err) => {
console.error("Error trying to read file", err);
};

let handleClick = () => Assignment.previewRawFile(fileName, reader.result);

$("#preview_map_file").click(handleClick);
}

Assignment.previewRawFile = function (fileName, fileContent) {
let newWindow = window.open("about:blank");
newWindow.document.write("<title>" + fileName + "</title>");
newWindow.document.write("<pre>" + fileContent + "</pre>");
}

}).call(this);
13 changes: 13 additions & 0 deletions app/assets/javascripts/jszip/jszip.min.js

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions app/assets/javascripts/password_resets.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

window.PasswordReset ||= {}

PasswordReset.validatePassword = ->
$("form#reset-password").submit (event) ->
if ($("div.new-password > input").val().length == 0)
$("div.new-password > p").text("New password cannot be blank").show();
event.preventDefault();
else if ($("div.new-password > input").val().length < 8)
$("div.new-password > p").text("New password must be at least 8 characters long").show();
event.preventDefault();
else if ($("div.new-password > input").val().match(/[a-z]+/) == null)
$("div.new-password > p").text("New password must contain at least 1 lower case character").show();
event.preventDefault();
else if ($("div.new-password > input").val().match(/[A-Z]+/) == null)
$("div.new-password > p").text("New password must contain at least 1 upper case character").show();
event.preventDefault();
else if ($("div.new-password > input").val().match(/[0-9~!@#$%^&*()+=|]+/) == null)
$("div.new-password > p").text("New password must contain at least 1 digit or special character").show();
event.preventDefault();

if ($("div.new-password > input").val() != $("div.confirm-new-password > input").val())
$("div.confirm-new-password > p").text("The password confirmation does not match").show();
event.preventDefault();
return
return

PasswordReset.resetForm = ->
$("div.new-password > input").keyup (event) ->
$("input.submit").removeAttr('disabled');
$("div.new-password > p").hide();
$("div.confirm-new-password > p").hide();

$("div.confirm-new-password > input").keyup (event) ->
$("input.submit").removeAttr('disabled');
$("div.new-password > p").hide();
$("div.confirm-new-password > p").hide();
return

$(document).ready ->
$ ->
PasswordReset.validatePassword()
PasswordReset.resetForm()
return
2 changes: 1 addition & 1 deletion app/assets/javascripts/site.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ $(document).ready ->
$(".site_header").addClass("site_header_background");
Site.setClipHeight($(this));

if (window.location.pathname && window.location.pathname.includes('login'))
if (window.location.pathname && !window.location.pathname.includes('cover'))
$(".site-login").addClass("site-login-hidden")
return
74 changes: 74 additions & 0 deletions app/assets/stylesheets/password_resets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Place all the styles related to the PasswordResets controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/

// This file is part of SSID.
//
// SSID is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SSID is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with SSID. If not, see <http://www.gnu.org/licenses/>.
@import "bootstrap_custom";

body.password_resets {
.site {
@extend .text-center;
width: 60%;
margin: auto;
}

.forget-password-helper-text {
@extend .mt-3;
@extend .mb-3;
}

.site_copyright {
@extend .mt-5;
@extend .mb-3;
@extend .text-muted;
}

.site-password-reset-link {
@extend .w-100;
@extend .btn;
@extend .btn-primary;
}

form#reset-password {
label {
margin-top: $spacer * 0.5;
}
}

.send-password-reset-link {
h5 {
margin-bottom: $spacer;
}

div {
p {
margin-bottom: $spacer * 0.5;
}
}
}

.reset-password {
h5 {
margin-bottom: $spacer;
}
}

.error-explanation {
color: var(--bs-danger);
display: none;
}
}

7 changes: 2 additions & 5 deletions app/assets/stylesheets/site.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ h2, h3, h4, h5, h6 {
}
}




.login_helper_text {
.forget-password-helper-text, .login_helper_text {
@extend .mt-3;
@extend .mb-3;
@extend .fw-normal;
Expand All @@ -140,7 +137,7 @@ h2, h3, h4, h5, h6 {
@extend .text-muted;
}

.site_login {
.site-password-reset-link, .site_login {
@extend .w-100;
@extend .btn;
@extend .btn-primary;
Expand Down
9 changes: 9 additions & 0 deletions app/assets/stylesheets/submission_logs.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ body.submission_logs {
@extend .table-hover;

margin-bottom: $spacer * 3;

td.view-similarity {
align-content: center;

img {
display: block;
margin: auto;
}
}
}
}
Loading

0 comments on commit 68609bc

Please sign in to comment.