Conversation
|
|
||
| function loadEditorContent() { | ||
| var editorValue = $window.localStorage.getItem("editor." + exercise.id + "." + editor.getOption("mode")); | ||
| if (editorValue != null) |
There was a problem hiding this comment.
It's one of the common best practices to use === and !== instead of == and != to prevent type coercion during comparison.
For more details about type coercion and why we want to avoid it, you can check this link: http://blog.jeremymartin.name/2008/03/understanding-loose-typing-in.html
|
Thanks for your work! I tested out you changes and, unfortunately, I spotted one issue with the current implementation: Basically, once you have stored one version of the code in the localStorage, you won't ever use again the code sent by the server anymore. It's not a problem if you always work using the same browser. But let's say you're using two different browsers. Once you started working on a exercise, you store your current code version into this browser's localStorage. So we need to add a mechanism to identify the more recent version of the code between the server's one and the localStorage's one so that we can choose which one to display. |
|
Cant we use git to save the data on the localstorage too? This way, git would deal with the issue for us. |
|
Student code is already stored in git. I thought the targeted goal of this PR (storing in localstorage) is to keep temporary student code (not yet compiled nor runned) in the browser. Of course, we could store it from time to time to the server (and therefore in git). But then, it means that we do not need localstorage at all, only pushing to the server more frequently (not only at a compilation request) the code written by a student. |
Use of localStorage to save the content of the editor