Save all data in one storage and display to a web page


#1

Hey guys,
I created a quiz game and published it on my WordPress website. I want to save all the results in one storage and then display it on a page? Would txt file do the job or do I need to save it in a database or something?

Thanks in advance!


#2

You would need to store it somewhere online, that’s for sure. The easiest way as of now would be to use Firebase Firestore.


#3

I read the documentation about network. Is that an option that I can use as well?


#4

You can but that would require you to code a server and would be unnecessarily harder than firebase, and very probably be less secure and performant and more expensive.


#5

Okay I will try use firebase then. But where do I start? I only want to save one variable to the database which is the total correct answer/result.


#6

You can always try one of my solutions if is just to store a score value.
https://www.wowscores.com/ or

examples for GDevelop for both projects.
Wow Scores you need to create your game and get API keys, the follow the example instructions to implement in your game.
Firebase is most robust and it’s worth for you to use it, but you can use one of those as an alternative.


#7

http://wiki.compilgames.net/doku.php/gdevelop5/all-features/firebase
It works very similarly to local storage.
I use the firebase firestore for saving and loading results.
But you want to display the results outside the game in a WordPress sidebar or something? Should be possible but also needs code. If you only have one variable for the game, the network/json solution should be simpler.


#8

Yes, I want to display the result on my WordPress page. I want to do the easiest way as I don’t have much time left for my project.


#9

Thanks for the help everyone! I will do my best.


#10


gameresult.php
<?php file_put_contents("gameresult.txt", $_GET["gameresult"]);?>


#11

i cannot upload a php file into the wordpress library?


#12

There is no need to upload into Wordpress Media, you create a php file like my_scores.php and upload to the root folder of your server usually is http_docs or www or public_html then you create into GDevelop the JSON request and point to the url where the file is hosted if you put the file in the root directory then must be
Send “Get” request to “https://www.yourdomain.com/my_scores.php” …
If you choose to upload the file to other location then change the url of the request to point that location: like
Send “Get” request to “https://www.yourdomain.com/my_great_game/my_scores.php” …
Hope this helps


#14

The txt will be created automatically if it doesn’t exist.
I think you don’t need “public” in the url, bc the domain is linked in this directory.

And the varibals are wrong.
You need 2, one for the saved result, to check if the current one is higher and the current one. You overwrite the loaded one and compares with a non-existent one.

If everything works, you should rename the php file and get-parameter-name, otherwise anyone who sees your screenshot can save any result.


#15

I want to store the result every time someone plays my game not highscore?


#16

I don’t know if that makes sense. But then you don’t need the first two events.
Only the one action, when you want to save.


#17

Sorry, I will clarify. I made an educational game. What I am trying to achieve is to get the results of each user who play my game in one storage and display them on our website so that the teachers can see how well the students do with the quiz.


#18

Ouw okay, that’s something completely different.
Sounds like you need accounts for every student?
Maybe you can draw graphically how the result site should look like.


#19

It doesn’t have to be fancy as long as it’s displaying the data.
image

If that seems to be hard to achieve, maybe at least even just display the result and don’t need to track the users. Because I know that needs more php coding for session


#20

Sorry to sound repetitive but WowScores is created specially to do what you want.


#21

UlisesFreitas, But I want the leaderboard to display into my wordpress website?