How do I make a simple flashcard program?

Get help using Construct 2

Post » Sun Jan 10, 2016 4:24 pm

I am trying to learn French so I have created an Excel file with about a thousand rows of French words and phrases, along with the English translations. I have exported the file to .csv and it looks like this:

Code: Select all
[ID,French,English]
1,Je m'appelle,My name is
2,Tu t'appelles,Your name is (informal)
3,Il s'appelle,His name is


How do I get this data into my Array object?

I added the .CSV to my Project files and I've successfully read it using AJAX. Should I use a "For" loop and "tokenat" to parse it into the Array (using "Insert")? It seems like Construct 2 prefers .json files so maybe I should just convert the Excel file to .json and read it into the array that way?

What's the best approach here? Any thoughts or suggestions will be appreciated!
B
11
S
3
Posts: 79
Reputation: 854

Post » Sun Jan 10, 2016 4:37 pm

If you're willing to use third party extensions, rexrainbow made a plugin to do just this.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Sun Jan 10, 2016 4:58 pm

Thanks for the reply. I was looking at the CSV2Array plugin as I thought it would let me download a CSV and add the data to an Array. But I don't think it works like that; I apparently have to copy my data and paste it into a small field. I have 1000 rows of words and sentences, and I wasn't sure if it would accept that much data. Do you know?

UPDATE: I just tried to convert my data to .json but the array feature "download json" doesn't do what I thought it did. Back to square one. Maybe my first approach is still the best.
B
11
S
3
Posts: 79
Reputation: 854

Post » Sun Jan 10, 2016 7:30 pm

John Cutter wrote:Thanks for the reply. I was looking at the CSV2Array plugin as I thought it would let me download a CSV and add the data to an Array. But I don't think it works like that; I apparently have to copy my data and paste it into a small field. I have 1000 rows of words and sentences, and I wasn't sure if it would accept that much data. Do you know?

UPDATE: I just tried to convert my data to .json but the array feature "download json" doesn't do what I thought it did. Back to square one. Maybe my first approach is still the best.


As far as I know, you can request the csv file with ajax and use tha ajax.lastdata with csvtoarray to fill the array with the csv-data.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 12, 2016 9:35 am

UPDATE: I wrote some VBA code in Excel to export my spreadsheet into C2's .json format. I made this a Project File and then used "AJAX.LastData" to "LOAD" the file into my array. Works great!

NEW QUESTIONS:
I want to make my web app available to my wife and other people in my French class. Ideally, the app will keep track of which words/phrases they get right and wrong so I can make the latter come up more often. I'll also need to add new words/phrases to the list by updating the .json file on the server.

What would be the best way to do this? Here's what I am currently considering:

PHRASES ARRAY:
[id] = Sequential numbering from 1 to the total number of cards. Doesn't change.
[french] = A French word/phrase
[english] = The English equivalent
[score] = This variable is used to determine how often that flashcard appears (based on whether players got it right or wrong)

LOCALSTORAGE:
[id]
[score]

Then I'll do something like this?

1. App starts - load Phrases Array from .json file on server
2. Load LocalStorage
3. Copy local [score] to array [score] by using the matching [id]

Then I'll show the Flashcards with the lowest score. If users get a card right then I'll raise the score. If they get a card wrong I'll lower the score.

If I store my Phrases Array with the [id] first and the [score] last then I should be able to sort the array on the X axis (sort by [id]). Or, Sort the array on the Y axis and then sort it on the X axis (sort by [score]). Right?
B
11
S
3
Posts: 79
Reputation: 854


Return to How do I....?

Who is online

Users browsing this forum: facecrime and 6 guests