Created
November 29, 2010 14:52
-
-
Save mark/720036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1) Search through the logs for the responses | |
# tail -n 1000000 current/log/production.log | grep '"id"=>"<EVALUATION RESPONSE ID GOES HERE>"' | |
# (2) Copy and paste results into output.txt file in the same directory as this, and then run this file | |
def print_responses(hsh) | |
needed = {} | |
hsh["responses"].keys.sort.each do |k| | |
v = hsh["responses"][k] | |
puts "#{k}\t#{ v["value"] }" if v["value"] | |
needed[k.to_i] = v["value"].to_i if v["value"] && ! v["value"].strip != "" | |
end | |
puts "Found #{needed.keys.length} keys" | |
puts | |
print "hash = " | |
puts needed.inspect | |
puts | |
end | |
contents = File.read("output.txt") | |
lines = contents.split("Parameters: ").map { |txt| eval(txt) }.compact.select { |hsh| hsh["responses"] } | |
lines.each { |l| print_responses l } | |
puts | |
# (3) In console, paste the following method: | |
def update_evaluation_responses(hash) | |
hash.each do |qr_id, value| | |
qr = QuestionResponse / qr_id | |
qr.value = value | |
qr.save | |
end | |
end | |
# (4) paste in the hash = {...} line and then call update_evaluation_responses(hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment