Loading static/js/exercises.api.mjs +14 −10 Original line number Diff line number Diff line /** API to create exercises */ import { getTerminalContents, getRawTerminalContents, runCommand, runUnexecutedCommand } from "./jslinux.api.mjs" import { getTerminalContents, getRawTerminalContents, runCommand, runUnexecutedCommand, abort, isVmLoading } from "./jslinux.api.mjs" import { arrayEquals } from "./util.mjs" import { getHandInToken } from "./snakeoil.mjs" import { State } from "./state.mjs" Loading Loading @@ -190,16 +190,20 @@ class ExerciseExecutionContext { if (getTerminalContents().length > 0) { // We have a prompt, so we can immediately run a command prepareAndResolve() } else { // We don't have a prompt, so wait until we do (by repeatedly checking) // TODO It might be that we never get a prompt, if an editor or pager is open. In this case, we should attempt to close the editor or pager. return } // We don't have a prompt, so wait until we do (by repeatedly checking). const intervalId = setInterval(() => { if (getTerminalContents().length > 0) { clearInterval(intervalId) prepareAndResolve() } else if(!isVmLoading()) { // If the vm is not loading, and we don't have a prompt, maybe the user has opened an editor or a pager. // Let's try Ctrl+C, maybe that will help us get out of this. abort() } }, 500) } }) } Loading Loading
static/js/exercises.api.mjs +14 −10 Original line number Diff line number Diff line /** API to create exercises */ import { getTerminalContents, getRawTerminalContents, runCommand, runUnexecutedCommand } from "./jslinux.api.mjs" import { getTerminalContents, getRawTerminalContents, runCommand, runUnexecutedCommand, abort, isVmLoading } from "./jslinux.api.mjs" import { arrayEquals } from "./util.mjs" import { getHandInToken } from "./snakeoil.mjs" import { State } from "./state.mjs" Loading Loading @@ -190,16 +190,20 @@ class ExerciseExecutionContext { if (getTerminalContents().length > 0) { // We have a prompt, so we can immediately run a command prepareAndResolve() } else { // We don't have a prompt, so wait until we do (by repeatedly checking) // TODO It might be that we never get a prompt, if an editor or pager is open. In this case, we should attempt to close the editor or pager. return } // We don't have a prompt, so wait until we do (by repeatedly checking). const intervalId = setInterval(() => { if (getTerminalContents().length > 0) { clearInterval(intervalId) prepareAndResolve() } else if(!isVmLoading()) { // If the vm is not loading, and we don't have a prompt, maybe the user has opened an editor or a pager. // Let's try Ctrl+C, maybe that will help us get out of this. abort() } }, 500) } }) } Loading