How do I Record Responses to local excel file?

0 favourites
From the Asset Store
Ludo Local Multiplayer board game can be played by 2 to 4 players
  • I'd like to have a game with a series of questions the player clicks through. As each question is answered, the answer is saved. At the end of the game, the data is sent to a local excel file or word document or whatever for the player to save. What is the easiest way I can do this?

    Thanks in advance!

  • Excels natively supports CSV format, which is a plain text with comma-separated values. So you can generate a string in Construct with all the data (separated by commas) and save it as a file with .CSV extension.

    You can google CSV examples to see how it's formatted.

    Another option is to send the data to Google Spreadsheet:

    construct.net/en/tutorials/sending-data-construct-23-1447

  • First, thank you!

    Second, can you explain how to generate a string or if there's a tutorial? That should help me move forward along with the other information you provided.

    Specifically, say I have a screen that has a question with two buttons: yes and no.

    And then I have 10 other screens with yes and no buttons as well. I want to record the choices and allow the user to download them to CSV, potentially with a date/time stamp.

  • You'll first need to store this data (questions and answers) somewhere, for example in an array.

    Here is an example how to export an array to csv:

    dropbox.com/s/sy2b1okfk9hymsu/ExportToCSV.c3p

  • Ahhh ok. I was hoping to avoid arrays because those are just over my head, haha.

    Thank you!

  • I figured out how to make an array work mostly.

    dop2000 - I have a one dimensional array of data, but when the csv downloads, it's just a bunch of 0's instead of the text I set to be added to the array.

    I'm trying to figure out how to fix that, as well as add a date and time stamp for each answer?

    Here's a picture of one of the array entries as well as my code to export

  • You can do this without arrays, just add each question+answer to the string variable as the player answers them. Use Date plugin to get the current date and time.

    For example:

    On leftclick of YesSprite: Set exportString to (exportString & questionNumber & "," & questionText & ",Yes," & Date.ToString(Date.Now) & newline)

  • Hmmm. So take out the array values through the whole thing? I've got a lot of

    if click on yes, then value is ___

    if click on no, then value is __

    So I'm just trying to get all those responses exported to csv with the date addon I've now used.

    I don't know why this is so hard for me to wrap my brain around!

  • I have a one dimensional array of data, but when the csv downloads, it's just a bunch of 0's instead of the text I set to be added to the array.

    Run the project in Debug Mode (Shift+F4) and check the contents of your array.

    Your event #16 on the screenshot runs on every tick, which is wrong. You need to move it as a sub-event to #17.

    And the MIME type needs to be "text/plain" or "text/text", not "s".

    But with 1D array you won't be able to send timestamps. I suggest using 2D array, or add question+answer+timestamp+newline to the string variable on every answer.

  • Ok, I will try making it 2 dimensional. Do you mind if I share the actual capx for you to look at, if I can figure out how?

  • Hmmm. So take out the array values through the whole thing? I've got a lot of

    This is not how quiz apps should be programmed. Even if there are hundreds of questions in the game, ideally you should have just one "On AnswerButton clicked" event.

    Use instance variables on the buttons to identify questions and answers.

  • So it would be a new instance variable on each layout, then export those responses to csv?

  • dop2000 I actually got it to let me save the responses to csv, I'm just trying to figure out now how to get the date and timestamp to go in!

  • See the Date plugin, there are different ways you can format the timestamp string.

    construct.net/en/make-games/manuals/construct-3/plugin-reference/date

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I would move all logic to instance variables on the Button sprite. (a single button for Yes and No answers)

    Configure these variables on each button for all questions.

    So when a button is clicked, you can compare its variables and know if the answer was correct or not, what to add to the CSV file and what to do next. This way you will only need one handling event for all questions in the quiz.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)