Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Fix assessment download submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwq committed Oct 29, 2015
1 parent 1961556 commit 86b50b9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions app/controllers/assessment/missions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,17 @@ def dump_code
end

sbms = @mission.submissions.
where("std_course_id IN (?) and status = 'graded'", std_courses.select("user_courses.id")).includes(:coding_answers)
where("std_course_id IN (?) and (status = 'graded' OR status = 'submitted')", std_courses.select("user_courses.id")).
includes(:coding_answers, :files)

result = nil

Dir.mktmpdir("mission-dump-temp-#{Time.now}") { |dir|
sbms.each do |sbm|
ans = sbm.coding_answers.first
unless ans
next
end

path = dir

if sbm.files.count > 0
if sbm.files.length > 0
title = sbm.std_course.name.gsub(/\//,"_")
dir_path = File.join(dir, title)
Dir.mkdir(dir_path) unless Dir.exists?(dir_path)
Expand All @@ -170,10 +167,12 @@ def dump_code
path = dir_path
end

title = "#{sbm.std_course.name.gsub(/\//,"_") }.py"
file = File.open(File.join(path, title), 'w+')
file.write(ans.content)
file.close
if ans
title = "#{sbm.std_course.name.gsub(/\//,"_") }.py"
file = File.open(File.join(path, title), 'w+')
file.write(ans.content)
file.close
end
end

zip_name = File.join(File.dirname(dir),
Expand Down

0 comments on commit 86b50b9

Please sign in to comment.