Skip to content

Commit

Permalink
Merge pull request #336 from autolab/hotfix_local_submit
Browse files Browse the repository at this point in the history
Removed extra CUD load
  • Loading branch information
Ilter committed Feb 25, 2015
2 parents 17e4cdb + 7336438 commit 7034a22
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/assessment/handin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def local_submit
begin
handinFile = params[:submit]

@cud = @course.course_user_data.find_by(email: @user.email)
if @assessment.max_submissions != -1 then
submission_count = @cud.submissions.where(assessment: @assessment).size
if submission_count >= @assessment.max_submissions then
Expand All @@ -96,6 +95,7 @@ def local_submit
begin
submissions = saveHandin({'local_submit_file'=>File.join(remoteHandinDir, handinFile)})
rescue Exception => e
puts "Error Saving Submission:\n#{e}"
submissions = nil
end

Expand All @@ -121,15 +121,15 @@ def local_submit
if (submissions) then
puts "Submission received, ID##{submissions[0].id}"
else
err = "There was an error saving your submission. Please contact your course staff"
err = "There was an error saving your submission. Please contact your course staff\n"
render plain: err, status: :bad_request and return
end

if @assessment.max_submissions != -1 then
render plain: " - You have #{assessment.max_submissions - submissons_count} submissions left" and return
render plain: " - You have #{assessment.max_submissions - submissons_count} submissions left\n" and return
end

render plain: "Successfully submitted" and return
render plain: "Successfully submitted\n" and return
else

# Create a handin directory for them.
Expand Down

0 comments on commit 7034a22

Please sign in to comment.