Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Tango unambiguous filenames for user handins #1947

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions app/helpers/assessment_autograde_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ def tango_upload(course, assessment, submission, existing_files)
COURSE_LOGGER.log("Error while uploading autograding files for #{submission.id}: missing file #{name_of_file}")
raise AutogradeError.new("Error while uploading autograding files", :missing_autograder_file, name_of_file)
end
if f["remoteFile"].nil?
f["remoteFile"] = File.basename(f["localFile"])
end
end

# now actually send all of the upload requests
upload_file_list.each do |f|
md5hash = Digest::MD5.file(f["localFile"]).to_s
next if (existing_files.has_key?(File.basename(f["localFile"])) &&
existing_files[File.basename(f["localFile"])] == md5hash)
next if (existing_files.has_key?(f["remoteFile"]) &&
existing_files[f["remoteFile"]] == md5hash)

begin
TangoClient.upload("#{course.name}-#{assessment.name}",
File.basename(f["localFile"]),
f["remoteFile"],
File.open(f["localFile"], "rb").read)
rescue TangoClient::TangoException => e
COURSE_LOGGER.log("Error while uploading autograding files for #{submission.id}: #{e.message}")
Expand Down Expand Up @@ -156,7 +159,7 @@ def get_job_status(job_id)
def tango_add_job(course, assessment, upload_file_list, callback_url, job_name, output_file)
job_properties = { "image" => @autograde_prop.autograde_image,
"files" => upload_file_list.map do |f|
{ "localFile" => File.basename(f["localFile"]),
{ "localFile" => f["remoteFile"],
"destFile" => Pathname.new(f["destFile"]).basename.to_s }
end,
"output_file" => output_file,
Expand Down Expand Up @@ -328,14 +331,17 @@ def autogradeInputFiles(ass_dir, assessment, submission)
# of files needed by the autograder. Can be overridden in the
# lab config file.
local_handin = submission.handin_file_path
remote_handin = submission.handin_file_long_filename
local_makefile = File.join(ass_dir, "autograde-Makefile")
local_autograde = File.join(ass_dir, "autograde.tar")

# Name of the handin file on the destination machine
dest_handin = assessment.handin_filename

# Construct the array of input files.
handin = { "localFile" => local_handin, "destFile" => dest_handin }
handin = { "localFile" => local_handin,
"remoteFile" => remote_handin,
"destFile" => dest_handin }
makefile = { "localFile" => local_makefile, "destFile" => "Makefile" }
autograde = { "localFile" => local_autograde, "destFile" => "autograde.tar" }

Expand Down
4 changes: 4 additions & 0 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def handin_file_filename
"#{version}_#{assessment.handin_filename}"
end

def handin_file_long_filename
"#{course_user_datum.email}_#{version}_#{assessment.handin_filename}"
end

def handin_file_path
return nil unless filename

Expand Down