Skip to content

Commit a02478f

Browse files
committed
Merge branch 'develop/autolab-3.0' into import-export-course
2 parents 6efde8c + bdb5682 commit a02478f

File tree

83 files changed

+1827
-1253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1827
-1253
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ doc/
5353
out.txt
5454
.vscode/
5555
.byebug_history
56-
56+
node_modules/
5757
# Credentials
5858
.env
5959

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ GEM
267267
stringio
268268
public_suffix (4.0.7)
269269
racc (1.6.1)
270-
rack (2.2.6.2)
270+
rack (2.2.6.4)
271271
rack-attack (6.6.1)
272272
rack (>= 1.0, < 3)
273273
rack-protection (2.2.0)

app/assets/javascripts/annotations.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,39 @@ function refreshAnnotations() {
8484
});
8585
}
8686

87+
// Updates relevant elements of the speedgrader when a new file is selected
88+
function loadFile(newFile) {
89+
// Update the code viewer and symbol tree with the cached data
90+
$('#code-box').replaceWith(newFile.codeBox);
91+
$('#symbol-tree-container').replaceWith(newFile.symbolTree);
92+
93+
// Add syntax highlighting to the new code viewer
94+
$('pre code').each(function () {
95+
hljs.highlightBlock(this);
96+
});
97+
98+
// Update the page URL
99+
history.replaceState(null, null, newFile.url);
100+
101+
// Update version dropdown
102+
$('#version-dropdown').replaceWith(newFile.versionDropdown);
103+
104+
// Update version buttons
105+
$('#version-links').replaceWith(newFile.versionLinks);
106+
107+
displayAnnotations();
108+
attachEvents();
109+
}
110+
87111
// Returns true if the file was cached, false otherwise
88112
function changeFile(headerPos) {
89113
$('#code-box').addClass('loading');
90114
setActiveFilePos(headerPos);
91115

92116
// If we've cached this file locally, just get it
93-
if (localCache[headerPos] != undefined) {
117+
if (localCache[headerPos] !== undefined) {
94118
newFile = localCache[headerPos];
95-
// Update the code viewer and symbol tree with the cached data
96-
$('#code-box').replaceWith(newFile.codeBox);
97-
$('#symbol-tree-container').replaceWith(newFile.symbolTree);
98-
99-
// Add syntax highlighting to the new code viewer
100-
$('pre code').each(function () {
101-
hljs.highlightBlock(this);
102-
});
103-
104-
// Update the page URL
105-
history.replaceState(null, null, newFile.url);
106-
107-
// Update version buttons
108-
$('#version-links').replaceWith(newFile.versionLinks);
109-
110-
displayAnnotations();
111-
attachEvents();
119+
loadFile(newFile);
112120
return true;
113121
}
114122
return false;
@@ -120,6 +128,7 @@ function purgeCurrentPageCache() {
120128
pdf: false,
121129
symbolTree: `<div id="symbol-tree-box">${$('#symbol-tree-box').html()}</div>`,
122130
versionLinks: `<span id="version-links">${$('#version-links').html()}</span>`,
131+
versionDropdown: `<span id="version-dropdown">${$('#version-dropdown').html()}</span>`,
123132
url: window.location.href,
124133
};
125134
}

app/assets/javascripts/git_submission.js

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
const github_endpoints = {
55
get_repos: '/github_integration/get_repositories',
6-
get_branches: '/github_integration/get_branches',
6+
get_branches: '/github_integration/get_branches',
7+
get_commits: '/github_integration/get_commits',
78
}
89

910
function update_repos() {
10-
$.getJSON(github_endpoints['get_repos'], function(data, status){
11+
$.getJSON(github_endpoints['get_repos'], function(data, status) {
1112
repos_html = "";
1213
data.forEach(repo => {
1314
repos_html += `<div class="item">${repo["repo_name"]}</div>`;
@@ -16,11 +17,24 @@ function update_repos() {
1617
});
1718
}
1819

19-
function update_branches(repo) {
20+
function clear_branches() {
2021
$("#branch-dropdown input[name='branch']").addClass("noselection");
2122
$("#branch-dropdown .text").addClass("default");
2223
$("#branch-dropdown .text").text("Select branch");
23-
$.getJSON(github_endpoints['get_branches'], {repository: repo}, function(data, status){
24+
$("#branch-dropdown .menu").html("");
25+
}
26+
27+
function clear_commits() {
28+
$("#commit-dropdown input[name='commit']").addClass("noselection");
29+
$("#commit-dropdown .text").addClass("default");
30+
$("#commit-dropdown .text").text("Select commit");
31+
$("#commit-dropdown .menu").html("");
32+
}
33+
34+
function update_branches(repo) {
35+
clear_branches();
36+
clear_commits();
37+
$.getJSON(github_endpoints['get_branches'], {repository: repo}, function(data, status) {
2438
branches_html = "";
2539
data.forEach(branch => {
2640
branches_html += `<div class="item">${branch["name"]}</div>`;
@@ -29,6 +43,17 @@ function update_branches(repo) {
2943
});
3044
}
3145

46+
function update_commits(repo, branch) {
47+
clear_commits();
48+
$.getJSON(github_endpoints['get_commits'], {repository: repo, branch: branch}, function(data, status) {
49+
commits_html = "";
50+
data.forEach(commit => {
51+
commits_html += `<div data-value="${commit["sha"]}" class="item">${commit["sha"]} (${commit["msg"]})</div>`;
52+
});
53+
$("#commit-dropdown .menu").html(commits_html);
54+
});
55+
}
56+
3257
$("a[data-tab=github]").click(function (e) {
3358
update_repos();
3459
});
@@ -38,6 +63,12 @@ $("#repo-dropdown").change(function() {
3863
update_branches(repo_name);
3964
});
4065

66+
$("#branch-dropdown").change(function() {
67+
var repo_name = $("#repo-dropdown input[name='repo']").val();
68+
var branch_name = $("#branch-dropdown input[name='branch']").val();
69+
update_commits(repo_name, branch_name);
70+
});
71+
4172
// https://stackoverflow.com/questions/5524045/jquery-non-ajax-post
4273
function submit(action, method, input) {
4374
'use strict';
@@ -65,8 +96,9 @@ $(document).on("click", "input[type='submit']", function (e) {
6596
e.preventDefault();
6697
var repo_name = $("#repo-dropdown input[name='repo']").val();
6798
var branch_name = $("#branch-dropdown input[name='branch']").val();
99+
var commit_sha = $("#commit-dropdown input[name='commit']").val();
68100
var token = $("meta[name=csrf-token]").attr("content");
69-
var params = {repo: repo_name, branch: branch_name, authenticity_token: token};
101+
var params = {repo: repo_name, branch: branch_name, commit: commit_sha, authenticity_token: token};
70102
var assessment_nav = $(".sub-navigation").find(".item").last();
71103
var assessment_url = assessment_nav.find("a").attr("href");
72104
var url = assessment_url + "/handin"
@@ -75,6 +107,7 @@ $(document).on("click", "input[type='submit']", function (e) {
75107
});
76108

77109
$(document).ready(function () {
110+
$('.ui.dropdown input[type="hidden"]').val("");
78111
$('.ui.dropdown').dropdown({
79112
fullTextSearch: true,
80113
});

app/assets/javascripts/table_floating_header.js

Lines changed: 0 additions & 147 deletions
This file was deleted.

app/assets/stylesheets/annotations.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.submission-controls select {
1515
height: 2rem;
1616
display: inline-block;
17-
width: 50px;
17+
width: 5ch;
1818
}
1919

2020
.submission-controls .btn {

app/assets/stylesheets/datatable.adapter.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ div.dataTables_paginate span>a {
6868
width: 15px;
6969
text-align: center;
7070
}
71+
72+
th {
73+
z-index: 1;
74+
position: sticky;
75+
top: 0;
76+
}

app/controllers/assessment/handin.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def handin
3737
github_integration = current_user.github_integration
3838

3939
begin
40-
@tarfile_path = github_integration.clone_repo(params["repo"], params["branch"], @assessment.max_size * (2 ** 20))
40+
@tarfile_path = github_integration.clone_repo(params["repo"], params["branch"], params["commit"], @assessment.max_size * (2 ** 20))
4141
rescue StandardError => msg
4242
flash[:error] = msg
4343
redirect_to(action: :show)
@@ -354,8 +354,6 @@ def validateHandin_forHTML
354354
return false
355355
end
356356

357-
validate_custom_form
358-
359357
validity = validateHandin(params[:submission]["file"].size,
360358
params[:submission]["file"].content_type,
361359
params[:submission]["file"].original_filename)
@@ -401,18 +399,6 @@ def validateHandinForGroups_forHTML
401399
return false
402400
end
403401

404-
def validate_custom_form
405-
# check if custom form exists
406-
if @assessment.has_custom_form
407-
for i in 0..@assessment.getTextfields.size - 1
408-
if params[:submission][("formfield" + (i + 1).to_s).to_sym].blank?
409-
flash[:error] = @assessment.getTextfields[i] + " is a required field."
410-
return false
411-
end
412-
end
413-
end
414-
end
415-
416402
def handle_validity(validity)
417403
case validity
418404
when :valid

0 commit comments

Comments
 (0)