evalentini / actprep

ACT test prep app
1 stars 0 forks source link

add ability to download csv file with answer statistics by user #25

Open evalentini opened 11 years ago

evalentini commented 11 years ago

should be a link on the usage report (answer dashboard) view to download all the answer data with user information appended (username/email in addition to id). Will eventually be used to analyze questions users are getting right/wrong more/less often.

MattCowski commented 11 years ago

I am getting an issue with routing. What am I doing wrong? In answers_controller.rb:

def dashboard
@answers = Answer.all
    respond_to do |format|
      format.csv { render text: @answers.to_csv }
    end
...

It should render this: http://asciicasts.com/system/photos/1239/original/E362I02.png

I just need a clue on how to fix routes and I will continue from there to make it download / xls format.

evalentini commented 11 years ago

If you are going to use respond_to you need to add a case for handling HTML

respond_to do |format| format.csv { render text: @answers.to_csv} format.html{ all the code that is in the controller action right now (or at least most of it)} end

There should be no code below the respond_to block.