Skip to content

Commit

Permalink
Only allow stopping the current code execution when started
Browse files Browse the repository at this point in the history
When a code execution is started, we shortly show a spinner on the Run button before it changes to Stop, allowing learners to abort the current code execution. However, previously, the Stop button was shown too early namely when the WebSocket connection was getting initialized. When it was immediately pressed after becoming available, it didn't had any effect.

With the changes of this commit, we delay showing the Stop button, so that it will be shown only once the runner is actually beginning with the code execution (as indicated by the `container_running` status).
  • Loading branch information
MrSerth committed Oct 15, 2024
1 parent f289500 commit 893ba7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/editor/editor.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@ var CodeOceanEditor = {

showStatus: function (output) {
switch (output.status) {
case 'container_running':
this.toggleButtonStates();
break;
case 'timeout':
case 'buffer_overflow':
this.showTimeoutMessage();
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/editor/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ CodeOceanEditorSubmissions = {
this.running = true;
this.showSpinner($('#run'));
$('#score_div').addClass('d-none');
this.toggleButtonStates();
await this.socketRunCode(submission.id, CodeOceanEditor.active_file.filename);
},

Expand Down

0 comments on commit 893ba7e

Please sign in to comment.