noams24 / Kef-Code

An educational website to help students easily pass tests
https://www.kefcode.com
MIT License
9 stars 19 forks source link

Sending a solution won't clear the text editor #137

Closed xarielah closed 4 months ago

xarielah commented 5 months ago

Problem: After sending a solution to a question, the text editor is not cleared, content is cached and still displays when returning to the question later on.

Reason: Kind of ruins it for the student if they want to rechallenge them selves with the same question.

Screenshot: image

noams24 commented 5 months ago

@xarielah What if the student wants to change or add details to their solution? Should I add submissions like in Leetcode?

xarielah commented 4 months ago

@xarielah What if the student wants to change or add details to their solution?

Should I add submissions like in Leetcode?

I'm not too familiar with submissions on Leetcode but maybe having an edit button on the solution that'll load the contents of the solution into the editor or transform the solution post into an editor and when the user saves the changes it'll update the content?

Btw I would advice having optimistic updates, it will make the interaction in general much smoother

noams24 commented 4 months ago

@xarielah ok I will think about how to implement it. Where do you think i should use optimistic updates? On which components?

xarielah commented 4 months ago

@xarielah ok I will think about how to implement it.

Where do you think i should use optimistic updates? On which components?

I would support implementing it where ever theres an interaction of a user and an asynchronous operation such as updating the solution, adding a question, liking, commenting etc...

Edit: I would research on useOptimistic

xarielah commented 4 months ago

@noams24 Btw wanted to also add here, that Next and react basically is all about caching the state, being reactive but only when ever you set it to be. For example (might be better to open as another issue or enhencment) I commented and someone's solution, switched between "תיאור" and "פתרונות" tabs, didn't see the comment counter change untill I refreshed.

noams24 commented 4 months ago

@noams24 Btw wanted to also add here, that Next and react basically is all about caching the state, being reactive but only when ever you set it to be. For example (might be better to open as another issue or enhencment) I commented and someone's solution, switched between "תיאור" and "פתרונות" tabs, didn't see the comment counter change untill I refreshed.

Thanks for noticing, I fixed it using react query invalidation. Should work fine now

noams24 commented 4 months ago

@xarielah image

I added submissions tab. Now you can delete your submission or copy an old one to your editor. Let me know what you think.

noams24 commented 4 months ago

@xarielah I close this issue for now, if you have another idea to improve please let me know