Open mgutierrezc opened 3 years ago
Okay, I'll take a look at this.
Cool, thanks! Just to avoid conflicts, could you work in a branch different than the JavaScript one?
Yes I can.
Hi @alkngo, would you tell me your progress on this issue?
Thanks
Hello, I've been busy the past few days, but I have been looking at the code, and I can't find the source of the issue yet. To tell you the truth, I'm not too familiar with the image-writing mechanism yet. If the bug in this takes too much time to find, could I suggest an alternative to the image-writing? I see you have now incorporated oTree live pages which is a more canon version of otree-redwood. In the original otree-redwood game I made, instead of writing to an image file, I was just storing a string of the number and sending that back and forth between client and server: (related code below)
Receiving and Sending on the Frontend: https://github.com/Leeps-Lab/random_number_game/blob/25af0af3f90d93533c66fd381412e8e3d3c8291c/static/random_number_game/random-number/random-number.js#L97-L127
Stylizing the number text like this would effectively turn the text to an image: https://github.com/Leeps-Lab/random_number_game/blob/25af0af3f90d93533c66fd381412e8e3d3c8291c/static/random_number_game/random-number/random-number.js#L44-L49
Receiving and Sending on the Backend: https://github.com/Leeps-Lab/random_number_game/blob/25af0af3f90d93533c66fd381412e8e3d3c8291c/models.py#L166-L185
I think we could simply translate this otree-redwood code to otree live pages code (unless the bug in your current code can be found). Thoughts?
No worries. If you feel you can implement your suggestion, feel free to do so. It looks like a good alternative to the current image-writing mechanism
On Tue, Mar 16, 2021 at 12:27 AM alkngo @.***> wrote:
Hello, I've been busy the past few days, but I have been looking at the code, and I can't find the source of the issue yet. To tell you the truth, I'm not too familiar with the image-writing mechanism yet. If the bug in this takes too much time to find, could I suggest an alternative to the image-writing? I see you have now incorporated oTree live pages which is a more canon version of otree-redwood. In the original otree-redwood game I made, instead of writing to an image file, I was just storing a string of the number and sending that back and forth between client and server: (related code below)
Receiving and Sending on the Frontend:
Stylizing the number text like this would effectively turn the text to an image:
Receiving and Sending on the Backend:
I think we could simply translate this otree-redwood code to otree live pages code (unless the bug in your current code can be found). Thoughts?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Leeps-Lab/random_number_game/issues/14#issuecomment-799961592, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKM2IYOL7H2GPP7Y6N3DKRLTD3T55ANCNFSM4YQLL7VA .
-- Marco Gutierrez Jefe de Práctica - Pontificia Universidad Católica del Perú
Ok, i will work on that then.
Actually, I think I might've found the error. Is it possible that in the frontend,
displayBase64Image(imagePlaceholder, base64Image);
Should be in liveRecv() instead of submit_transcription() ?
I haven't thought of that. Have you tested that this change works?
On Tue, Mar 16, 2021 at 7:45 PM alkngo @.***> wrote:
15 https://github.com/Leeps-Lab/random_number_game/pull/15
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Leeps-Lab/random_number_game/issues/14#issuecomment-800709526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKM2IYNEWUZRXRTERQWTXBLTD73RZANCNFSM4YQLL7VA .
-- Marco Gutierrez Jefe de Práctica - Pontificia Universidad Católica del Perú
I've tested it, and the game still works. I think it does show the number from the right stage number now. Although, the first round still shows no number, which is by design right?
Cool. It should display the number on the first round though. Any ideas about that?
El El mar, mar. 16, 2021 a las 8:02 p. m., alkngo @.***> escribió:
I've tested it, and the game still works. I think it does show the number from the right stage number now. Although, the first round still shows no number, which is by design right?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Leeps-Lab/random_number_game/issues/14#issuecomment-800715615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKM2IYKWYJKHBEFWZHZ3LYLTD75UDANCNFSM4YQLL7VA .
-- Marco Gutierrez Jefe de Práctica - Pontificia Universidad Católica del Perú
I'll look into it some more.
It looks like the step of loading the first image had to be done separately from the rest. I finished that, and I think everything should be good now.
16
It looks like the step of loading the first image had to be done separately from the rest. I finished that, and I think everything should be good now.
You are right. The images are being displayed correctly now. Thanks for your help!
No problem, apologies for the long delay!
Hi @alkngo,
While debugging the code, I noticed that the issue is still there. The images are displayed correctly, but the numbers they present are from a previous round.
For example, lets consider the following numbers for rounds 1-3 provided by the previous image:
round 1: 679341528 round 2: 612897354 round 3: 481925367
When the player is in round 2, the image is displaying the number 679341528 (from round 1) When the player is in round 3, the image is displaying the number 612897354 (from round 1)
This also happens with round 1, but the number displayed appears from nowhere (I guess this has to do with the order in which the js and python code for the task is executed)
Would you check what is causing this weird issue?
17 I think this should fix it. I just reordered some stuff around.
It works! Thanks!
Hi @alkngo, looks like this still has some issues. When starting the first round, there are times in which the image displayed is not the image registered by the backend. For example, this happened in the stage 2 of a demo session :
DEBUG: task_number = 451693827
DEBUG: transcription = 136984527
Would you give a look at it please?
Hi @alkngo, looks like this still has some issues. When starting the first round, there are times in which the image displayed is not the image registered by the backend. For example, this happened in the stage 2 of a demo session :
DEBUG: task_number = 451693827 DEBUG: transcription = 136984527
Would you give a look at it please?
I've noticed this happens when there is a timeout on the previous stage
Hey, sorry for the delay. I think #18 may fix it. I had misinterpreted when before_next_page() would be called, but I think moving the contents of that function to the creating_vars() function will make the first number assignment accurate.
Hi @alkngo,
I've managed to create an optimized version of the code using JS, but there is a problem I would like your help with.
In each stage, the code is displaying the task numbers as images starting from the third round. However, when an image is displayed, it is the one from the previous round.
The code for displaying the images is the following:
https://github.com/Leeps-Lab/random_number_game/blob/79f09e192a5b6a7f31b829c044e2bbcbb1208417/templates/random_number_game/Decision.html#L15
In
{% block scripts %}
: https://github.com/Leeps-Lab/random_number_game/blob/79f09e192a5b6a7f31b829c044e2bbcbb1208417/templates/random_number_game/Decision.html#L33-L45https://github.com/Leeps-Lab/random_number_game/blob/79f09e192a5b6a7f31b829c044e2bbcbb1208417/templates/random_number_game/Decision.html#L58
https://github.com/Leeps-Lab/random_number_game/blob/79f09e192a5b6a7f31b829c044e2bbcbb1208417/templates/random_number_game/Decision.html#L73
Converting the number to image https://github.com/Leeps-Lab/random_number_game/blob/79f09e192a5b6a7f31b829c044e2bbcbb1208417/models.py#L318-L335