Commit f6820f8d378bcf2c9ac92b8b6eaf324d1deab67c

Authored by Dhruv Kapadia
1 parent 82c86c12

Format changes in item and vote export

Showing 1 changed file with 5 additions and 2 deletions   Show diff stats
app/controllers/questions_controller.rb
@@ -103,7 +103,7 @@ class QuestionsController < InheritedResources::Base @@ -103,7 +103,7 @@ class QuestionsController < InheritedResources::Base
103 @question = Question.find(params[:id]) 103 @question = Question.find(params[:id])
104 104
105 outfile = "question_#{@question.id}_votes" + Time.now.strftime("%m-%d-%Y") + ".csv" 105 outfile = "question_#{@question.id}_votes" + Time.now.strftime("%m-%d-%Y") + ".csv"
106 - headers = ['Vote ID', 'Voter ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text', 106 + headers = ['Vote ID', 'Session ID', 'Question ID','Winner ID', 'Winner Text', 'Loser ID', 'Loser Text',
107 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at'] 107 'Prompt ID', 'Left Choice ID', 'Right Choice ID', 'Created at', 'Updated at']
108 @votes = @question.votes 108 @votes = @question.votes
109 csv_data = FasterCSV.generate do |csv| 109 csv_data = FasterCSV.generate do |csv|
@@ -135,8 +135,11 @@ class QuestionsController < InheritedResources::Base @@ -135,8 +135,11 @@ class QuestionsController < InheritedResources::Base
135 135
136 csv_data = FasterCSV.generate do |csv| 136 csv_data = FasterCSV.generate do |csv|
137 csv << headers 137 csv << headers
  138 +
  139 + #ensure capital format for true and false
  140 + user_sumbmitted = (c.item.creator != @question.creator) ? "TRUE" : "FALSE"
138 @question.choices.each do |c| 141 @question.choices.each do |c|
139 - csv << [ c.id, c.item_id, "'#{c.data.strip}'", c.question_id, c.item.creator != @question.creator, c.item.creator_id, 142 + csv << [ c.id, c.item_id, "'#{c.data.strip}'", c.question_id, user_submitted , c.item.creator_id,
140 c.wins, c.losses, c.created_at, c.updated_at, c.active, c.score, c.local_identifier, 143 c.wins, c.losses, c.created_at, c.updated_at, c.active, c.score, c.local_identifier,
141 c.prompts_on_the_left(true).size, c.prompts_on_the_right(true).size, c.prompts_count] 144 c.prompts_on_the_left(true).size, c.prompts_on_the_right(true).size, c.prompts_count]
142 end 145 end