allow running, testing and scoring of files in subfolders by using the full filepath
This commit is contained in:
@ -270,8 +270,8 @@ configureEditors: function () {
|
|||||||
$('#files').jstree($('#files').data('entries'));
|
$('#files').jstree($('#files').data('entries'));
|
||||||
$('#files').on('click', 'li.jstree-leaf', function (event) {
|
$('#files').on('click', 'li.jstree-leaf', function (event) {
|
||||||
this.setActiveFile(
|
this.setActiveFile(
|
||||||
filename: $(event.target).parent().text(),
|
$(event.target).parent().text(),
|
||||||
id: parseInt($(event.target).parent().attr('id'))
|
parseInt($(event.target).parent().attr('id'))
|
||||||
);
|
);
|
||||||
var frame = $('[data-file-id="' + this.active_file.id + '"]').parent();
|
var frame = $('[data-file-id="' + this.active_file.id + '"]').parent();
|
||||||
this.showFrame(frame);
|
this.showFrame(frame);
|
||||||
|
@ -2,8 +2,9 @@ CodeOceanEditorWebsocket = {
|
|||||||
websocket: null,
|
websocket: null,
|
||||||
|
|
||||||
createSocketUrl: function(url) {
|
createSocketUrl: function(url) {
|
||||||
var sockURL = new URL(window.location);
|
var sockURL = new URL(url, window.location);
|
||||||
sockURL.pathname = url;
|
// not needed any longer, we put it directly into the url: sockURL.pathname = url;
|
||||||
|
|
||||||
// sanitize socket protocol string, strip trailing slash and other malicious chars if they are there
|
// sanitize socket protocol string, strip trailing slash and other malicious chars if they are there
|
||||||
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:';
|
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:';
|
||||||
|
|
||||||
|
@ -80,6 +80,14 @@ module CodeOcean
|
|||||||
end
|
end
|
||||||
private :content_present?
|
private :content_present?
|
||||||
|
|
||||||
|
def filepath
|
||||||
|
if path.present?
|
||||||
|
::File.join(path, name_with_extension)
|
||||||
|
else
|
||||||
|
name_with_extension
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def hash_content
|
def hash_content
|
||||||
self.hashed_content = Digest::MD5.new.hexdigest(file_type.try(:binary?) ? ::File.new(native_file.file.path, 'r').read : content)
|
self.hashed_content = Digest::MD5.new.hexdigest(file_type.try(:binary?) ? ::File.new(native_file.file.path, 'r').read : content)
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,11 @@ class DockerClient
|
|||||||
end
|
end
|
||||||
|
|
||||||
def command_substitutions(filename)
|
def command_substitutions(filename)
|
||||||
{class_name: File.basename(filename, File.extname(filename)).camelize, filename: filename, module_name: File.basename(filename, File.extname(filename)).underscore}
|
{
|
||||||
|
class_name: File.basename(filename, File.extname(filename)).camelize,
|
||||||
|
filename: filename,
|
||||||
|
module_name: File.basename(filename, File.extname(filename)).underscore
|
||||||
|
}
|
||||||
end
|
end
|
||||||
private :command_substitutions
|
private :command_substitutions
|
||||||
|
|
||||||
@ -310,7 +314,8 @@ class DockerClient
|
|||||||
"""
|
"""
|
||||||
Run commands by attaching a websocket to Docker.
|
Run commands by attaching a websocket to Docker.
|
||||||
"""
|
"""
|
||||||
command = submission.execution_environment.run_command % command_substitutions(filename)
|
filepath = submission.collect_files.find{|f| f.name_with_extension == filename}.filepath
|
||||||
|
command = submission.execution_environment.run_command % command_substitutions(filepath)
|
||||||
create_workspace_files = proc { create_workspace_files(container, submission) }
|
create_workspace_files = proc { create_workspace_files(container, submission) }
|
||||||
open_websocket_connection(command, create_workspace_files, block)
|
open_websocket_connection(command, create_workspace_files, block)
|
||||||
# actual run command is run in the submissions controller, after all listeners are attached.
|
# actual run command is run in the submissions controller, after all listeners are attached.
|
||||||
@ -320,7 +325,8 @@ class DockerClient
|
|||||||
"""
|
"""
|
||||||
Stick to existing Docker API with exec command.
|
Stick to existing Docker API with exec command.
|
||||||
"""
|
"""
|
||||||
command = submission.execution_environment.test_command % command_substitutions(filename)
|
filepath = submission.collect_files.find{|f| f.name_with_extension == filename}.filepath
|
||||||
|
command = submission.execution_environment.test_command % command_substitutions(filepath)
|
||||||
create_workspace_files = proc { create_workspace_files(container, submission) }
|
create_workspace_files = proc { create_workspace_files(container, submission) }
|
||||||
execute_command(command, create_workspace_files, block)
|
execute_command(command, create_workspace_files, block)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user