diff --git a/oer/courses/c-advanced/sections/01-introduction/00-weclome/content.md b/oer/courses/c-advanced/sections/01-introduction/00-welcome/content.md similarity index 100% rename from oer/courses/c-advanced/sections/01-introduction/00-weclome/content.md rename to oer/courses/c-advanced/sections/01-introduction/00-welcome/content.md diff --git a/oer/courses/c-advanced/sections/01-introduction/00-weclome/meta b/oer/courses/c-advanced/sections/01-introduction/00-welcome/meta similarity index 100% rename from oer/courses/c-advanced/sections/01-introduction/00-weclome/meta rename to oer/courses/c-advanced/sections/01-introduction/00-welcome/meta diff --git a/oer/courses/c-advanced/sections/01-introduction/00-weclome/type b/oer/courses/c-advanced/sections/01-introduction/00-welcome/type similarity index 100% rename from oer/courses/c-advanced/sections/01-introduction/00-weclome/type rename to oer/courses/c-advanced/sections/01-introduction/00-welcome/type diff --git a/oer/courses/c-mpi/sections/01-introduction/01-c-hello/execute.sh b/oer/courses/c-mpi/sections/01-introduction/01-c-hello/execute.sh new file mode 100755 index 0000000..46098c7 --- /dev/null +++ b/oer/courses/c-mpi/sections/01-introduction/01-c-hello/execute.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mpiexec -n 2 ./program diff --git a/oer/courses/c-mpi/sections/01-introduction/01-c-hello/job.slurm b/oer/courses/c-mpi/sections/01-introduction/01-c-hello/job.slurm deleted file mode 100644 index 07240f1..0000000 --- a/oer/courses/c-mpi/sections/01-introduction/01-c-hello/job.slurm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -#SBATCH -N 2 -mpiexec program diff --git a/oer/courses/c-mpi/sections/01-introduction/02-bcast/execute.sh b/oer/courses/c-mpi/sections/01-introduction/02-bcast/execute.sh new file mode 100755 index 0000000..46098c7 --- /dev/null +++ b/oer/courses/c-mpi/sections/01-introduction/02-bcast/execute.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mpiexec -n 2 ./program diff --git a/oer/courses/c-mpi/sections/01-introduction/02-bcast/job.slurm b/oer/courses/c-mpi/sections/01-introduction/02-bcast/job.slurm deleted file mode 100644 index 0d617e3..0000000 --- a/oer/courses/c-mpi/sections/01-introduction/02-bcast/job.slurm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -#SBATCH -n 4 -mpiexec program diff --git a/oer/exercise-formats/program/Session.vim b/oer/exercise-formats/program/Session.vim deleted file mode 100644 index 193cd1c..0000000 --- a/oer/exercise-formats/program/Session.vim +++ /dev/null @@ -1,541 +0,0 @@ -let SessionLoad = 1 -if &cp | set nocp | endif -let s:cpo_save=&cpo -set cpo&vim -nmap gx NetrwBrowseX -nnoremap NetrwBrowseX :call netrw#NetrwBrowseX(expand(""),0) -let &cpo=s:cpo_save -unlet s:cpo_save -set autoindent -set backspace=indent,eol,start -set copyindent -set expandtab -set fileencodings=ucs-bom,utf-8,default,latin1 -set helplang=en -set laststatus=2 -set mouse=a -set printoptions=paper:a4 -set ruler -set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after -set shiftround -set shiftwidth=4 -set smarttab -set softtabstop=4 -set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc -set tabstop=4 -set wildmenu -set wildmode=list:longest,full -let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0 -let v:this_session=expand(":p") -silent only -cd ~/git/HOOU/oer/exercise-formats/program -if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' - let s:wipebuf = bufnr('%') -endif -set shortmess=aoO -badd +0 match-regex-parallel/controller.py -badd +0 match-regex-parallel/ExerciseHandler.py -badd +0 ../../../django-platform/runner/tasks.py -badd +0 match-regex-parallel/script.js -argglobal -silent! argdel * -set stal=2 -edit match-regex-parallel/controller.py -set splitbelow splitright -set nosplitbelow -set nosplitright -wincmd t -set winheight=1 winwidth=1 -argglobal -setlocal keymap= -setlocal noarabic -setlocal autoindent -setlocal backupcopy= -setlocal balloonexpr= -setlocal nobinary -setlocal nobreakindent -setlocal breakindentopt= -setlocal bufhidden= -setlocal buflisted -setlocal buftype= -setlocal nocindent -setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e -setlocal cinoptions= -setlocal cinwords=if,else,while,do,for,switch -set colorcolumn=80 -setlocal colorcolumn=80 -setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- -setlocal commentstring=/*%s*/ -setlocal complete=.,w,b,u,t,i -setlocal concealcursor= -setlocal conceallevel=0 -setlocal completefunc= -setlocal copyindent -setlocal cryptmethod= -setlocal nocursorbind -setlocal nocursorcolumn -setlocal nocursorline -setlocal define= -setlocal dictionary= -setlocal nodiff -setlocal equalprg= -setlocal errorformat= -setlocal expandtab -if &filetype != 'python' -setlocal filetype=python -endif -setlocal foldcolumn=0 -setlocal foldenable -setlocal foldexpr=0 -setlocal foldignore=# -setlocal foldlevel=0 -setlocal foldmarker={{{,}}} -setlocal foldmethod=manual -setlocal foldminlines=1 -setlocal foldnestmax=20 -setlocal foldtext=foldtext() -setlocal formatexpr= -setlocal formatoptions=tcq -setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* -setlocal grepprg= -setlocal iminsert=2 -setlocal imsearch=2 -setlocal include= -setlocal includeexpr= -setlocal indentexpr= -setlocal indentkeys=0{,0},:,0#,!^F,o,O,e -setlocal noinfercase -setlocal iskeyword=@,48-57,_,192-255 -setlocal keywordprg= -setlocal nolinebreak -setlocal nolisp -setlocal lispwords= -setlocal nolist -setlocal makeprg= -setlocal matchpairs=(:),{:},[:] -setlocal modeline -setlocal modifiable -setlocal nrformats=octal,hex -set number -setlocal number -setlocal numberwidth=4 -setlocal omnifunc= -setlocal path= -setlocal nopreserveindent -setlocal nopreviewwindow -setlocal quoteescape=\\ -setlocal noreadonly -setlocal norelativenumber -setlocal norightleft -setlocal rightleftcmd=search -setlocal noscrollbind -setlocal shiftwidth=4 -setlocal noshortname -setlocal nosmartindent -setlocal softtabstop=4 -setlocal nospell -setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ -setlocal spellfile= -setlocal spelllang=en -setlocal statusline= -setlocal suffixesadd= -setlocal swapfile -setlocal synmaxcol=3000 -if &syntax != 'python' -setlocal syntax=python -endif -setlocal tabstop=4 -setlocal tags= -setlocal textwidth=0 -setlocal thesaurus= -setlocal noundofile -setlocal undolevels=-123456 -setlocal nowinfixheight -setlocal nowinfixwidth -setlocal wrap -setlocal wrapmargin=0 -silent! normal! zE -let s:l = 46 - ((6 * winheight(0) + 32) / 65) -if s:l < 1 | let s:l = 1 | endif -exe s:l -normal! zt -46 -normal! 0 -tabedit match-regex-parallel/script.js -set splitbelow splitright -set nosplitbelow -set nosplitright -wincmd t -set winheight=1 winwidth=1 -argglobal -setlocal keymap= -setlocal noarabic -setlocal autoindent -setlocal backupcopy= -setlocal balloonexpr= -setlocal nobinary -setlocal nobreakindent -setlocal breakindentopt= -setlocal bufhidden= -setlocal buflisted -setlocal buftype= -setlocal nocindent -setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e -setlocal cinoptions= -setlocal cinwords=if,else,while,do,for,switch -set colorcolumn=80 -setlocal colorcolumn=80 -setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- -setlocal commentstring=/*%s*/ -setlocal complete=.,w,b,u,t,i -setlocal concealcursor= -setlocal conceallevel=0 -setlocal completefunc= -setlocal copyindent -setlocal cryptmethod= -setlocal nocursorbind -setlocal nocursorcolumn -setlocal nocursorline -setlocal define= -setlocal dictionary= -setlocal nodiff -setlocal equalprg= -setlocal errorformat= -setlocal expandtab -if &filetype != 'javascript' -setlocal filetype=javascript -endif -setlocal foldcolumn=0 -setlocal foldenable -setlocal foldexpr=0 -setlocal foldignore=# -setlocal foldlevel=0 -setlocal foldmarker={{{,}}} -setlocal foldmethod=manual -setlocal foldminlines=1 -setlocal foldnestmax=20 -setlocal foldtext=foldtext() -setlocal formatexpr= -setlocal formatoptions=tcq -setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* -setlocal grepprg= -setlocal iminsert=2 -setlocal imsearch=2 -setlocal include= -setlocal includeexpr= -setlocal indentexpr= -setlocal indentkeys=0{,0},:,0#,!^F,o,O,e -setlocal noinfercase -setlocal iskeyword=@,48-57,_,192-255 -setlocal keywordprg= -setlocal nolinebreak -setlocal nolisp -setlocal lispwords= -setlocal nolist -setlocal makeprg= -setlocal matchpairs=(:),{:},[:] -setlocal modeline -setlocal modifiable -setlocal nrformats=octal,hex -set number -setlocal number -setlocal numberwidth=4 -setlocal omnifunc= -setlocal path= -setlocal nopreserveindent -setlocal nopreviewwindow -setlocal quoteescape=\\ -setlocal noreadonly -setlocal norelativenumber -setlocal norightleft -setlocal rightleftcmd=search -setlocal noscrollbind -setlocal shiftwidth=4 -setlocal noshortname -setlocal nosmartindent -setlocal softtabstop=4 -setlocal nospell -setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ -setlocal spellfile= -setlocal spelllang=en -setlocal statusline= -setlocal suffixesadd= -setlocal swapfile -setlocal synmaxcol=3000 -if &syntax != 'javascript' -setlocal syntax=javascript -endif -setlocal tabstop=4 -setlocal tags= -setlocal textwidth=0 -setlocal thesaurus= -setlocal noundofile -setlocal undolevels=-123456 -setlocal nowinfixheight -setlocal nowinfixwidth -setlocal wrap -setlocal wrapmargin=0 -silent! normal! zE -let s:l = 107 - ((52 * winheight(0) + 32) / 65) -if s:l < 1 | let s:l = 1 | endif -exe s:l -normal! zt -107 -normal! 020| -tabedit match-regex-parallel/ExerciseHandler.py -set splitbelow splitright -set nosplitbelow -set nosplitright -wincmd t -set winheight=1 winwidth=1 -argglobal -setlocal keymap= -setlocal noarabic -setlocal autoindent -setlocal backupcopy= -setlocal balloonexpr= -setlocal nobinary -setlocal nobreakindent -setlocal breakindentopt= -setlocal bufhidden= -setlocal buflisted -setlocal buftype= -setlocal nocindent -setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e -setlocal cinoptions= -setlocal cinwords=if,else,while,do,for,switch -set colorcolumn=80 -setlocal colorcolumn=80 -setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- -setlocal commentstring=/*%s*/ -setlocal complete=.,w,b,u,t,i -setlocal concealcursor= -setlocal conceallevel=0 -setlocal completefunc= -setlocal copyindent -setlocal cryptmethod= -setlocal nocursorbind -setlocal nocursorcolumn -setlocal nocursorline -setlocal define= -setlocal dictionary= -setlocal nodiff -setlocal equalprg= -setlocal errorformat= -setlocal expandtab -if &filetype != 'python' -setlocal filetype=python -endif -setlocal foldcolumn=0 -setlocal foldenable -setlocal foldexpr=0 -setlocal foldignore=# -setlocal foldlevel=0 -setlocal foldmarker={{{,}}} -setlocal foldmethod=manual -setlocal foldminlines=1 -setlocal foldnestmax=20 -setlocal foldtext=foldtext() -setlocal formatexpr= -setlocal formatoptions=tcq -setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* -setlocal grepprg= -setlocal iminsert=2 -setlocal imsearch=2 -setlocal include= -setlocal includeexpr= -setlocal indentexpr= -setlocal indentkeys=0{,0},:,0#,!^F,o,O,e -setlocal noinfercase -setlocal iskeyword=@,48-57,_,192-255 -setlocal keywordprg= -setlocal nolinebreak -setlocal nolisp -setlocal lispwords= -setlocal nolist -setlocal makeprg= -setlocal matchpairs=(:),{:},[:] -setlocal modeline -setlocal modifiable -setlocal nrformats=octal,hex -set number -setlocal number -setlocal numberwidth=4 -setlocal omnifunc= -setlocal path= -setlocal nopreserveindent -setlocal nopreviewwindow -setlocal quoteescape=\\ -setlocal noreadonly -setlocal norelativenumber -setlocal norightleft -setlocal rightleftcmd=search -setlocal noscrollbind -setlocal shiftwidth=4 -setlocal noshortname -setlocal nosmartindent -setlocal softtabstop=4 -setlocal nospell -setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ -setlocal spellfile= -setlocal spelllang=en -setlocal statusline= -setlocal suffixesadd= -setlocal swapfile -setlocal synmaxcol=3000 -if &syntax != 'python' -setlocal syntax=python -endif -setlocal tabstop=4 -setlocal tags= -setlocal textwidth=0 -setlocal thesaurus= -setlocal noundofile -setlocal undolevels=-123456 -setlocal nowinfixheight -setlocal nowinfixwidth -setlocal wrap -setlocal wrapmargin=0 -silent! normal! zE -let s:l = 32 - ((31 * winheight(0) + 32) / 65) -if s:l < 1 | let s:l = 1 | endif -exe s:l -normal! zt -32 -normal! 041| -tabedit ../../../django-platform/runner/tasks.py -set splitbelow splitright -set nosplitbelow -set nosplitright -wincmd t -set winheight=1 winwidth=1 -argglobal -setlocal keymap= -setlocal noarabic -setlocal autoindent -setlocal backupcopy= -setlocal balloonexpr= -setlocal nobinary -setlocal nobreakindent -setlocal breakindentopt= -setlocal bufhidden= -setlocal buflisted -setlocal buftype= -setlocal nocindent -setlocal cinkeys=0{,0},0),:,0#,!^F,o,O,e -setlocal cinoptions= -setlocal cinwords=if,else,while,do,for,switch -set colorcolumn=80 -setlocal colorcolumn=80 -setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- -setlocal commentstring=/*%s*/ -setlocal complete=.,w,b,u,t,i -setlocal concealcursor= -setlocal conceallevel=0 -setlocal completefunc= -setlocal copyindent -setlocal cryptmethod= -setlocal nocursorbind -setlocal nocursorcolumn -setlocal nocursorline -setlocal define= -setlocal dictionary= -setlocal nodiff -setlocal equalprg= -setlocal errorformat= -setlocal expandtab -if &filetype != 'python' -setlocal filetype=python -endif -setlocal foldcolumn=0 -setlocal foldenable -setlocal foldexpr=0 -setlocal foldignore=# -setlocal foldlevel=0 -setlocal foldmarker={{{,}}} -setlocal foldmethod=manual -setlocal foldminlines=1 -setlocal foldnestmax=20 -setlocal foldtext=foldtext() -setlocal formatexpr= -setlocal formatoptions=tcq -setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* -setlocal grepprg= -setlocal iminsert=2 -setlocal imsearch=2 -setlocal include= -setlocal includeexpr= -setlocal indentexpr= -setlocal indentkeys=0{,0},:,0#,!^F,o,O,e -setlocal noinfercase -setlocal iskeyword=@,48-57,_,192-255 -setlocal keywordprg= -setlocal nolinebreak -setlocal nolisp -setlocal lispwords= -setlocal nolist -setlocal makeprg= -setlocal matchpairs=(:),{:},[:] -setlocal modeline -setlocal modifiable -setlocal nrformats=octal,hex -set number -setlocal number -setlocal numberwidth=4 -setlocal omnifunc= -setlocal path= -setlocal nopreserveindent -setlocal nopreviewwindow -setlocal quoteescape=\\ -setlocal noreadonly -setlocal norelativenumber -setlocal norightleft -setlocal rightleftcmd=search -setlocal noscrollbind -setlocal shiftwidth=4 -setlocal noshortname -setlocal nosmartindent -setlocal softtabstop=4 -setlocal nospell -setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ -setlocal spellfile= -setlocal spelllang=en -setlocal statusline= -setlocal suffixesadd= -setlocal swapfile -setlocal synmaxcol=3000 -if &syntax != 'python' -setlocal syntax=python -endif -setlocal tabstop=4 -setlocal tags= -setlocal textwidth=0 -setlocal thesaurus= -setlocal noundofile -setlocal undolevels=-123456 -setlocal nowinfixheight -setlocal nowinfixwidth -setlocal wrap -setlocal wrapmargin=0 -silent! normal! zE -let s:l = 1 - ((0 * winheight(0) + 32) / 65) -if s:l < 1 | let s:l = 1 | endif -exe s:l -normal! zt -1 -normal! 0 -tabnext 2 -set stal=1 -if exists('s:wipebuf') - silent exe 'bwipe ' . s:wipebuf -endif -unlet! s:wipebuf -set winheight=1 winwidth=20 shortmess=filnxtToO -let s:sx = expand(":p:r")."x.vim" -if file_readable(s:sx) - exe "source " . fnameescape(s:sx) -endif -let &so = s:so_save | let &siso = s:siso_save -doautoall SessionLoadPost -unlet SessionLoad -" vim: set ft=vim : diff --git a/oer/exercise-formats/program/match-regex-parallel/.script.js.swp b/oer/exercise-formats/program/match-regex-parallel/.script.js.swp deleted file mode 100644 index 456ee3b..0000000 Binary files a/oer/exercise-formats/program/match-regex-parallel/.script.js.swp and /dev/null differ diff --git a/oer/exercise-formats/program/match-regex-parallel/controller.py b/oer/exercise-formats/program/match-regex-parallel/controller.py index 8eb2f19..a3c9296 100644 --- a/oer/exercise-formats/program/match-regex-parallel/controller.py +++ b/oer/exercise-formats/program/match-regex-parallel/controller.py @@ -36,23 +36,26 @@ def execute(ctx): if ctx.build_result[0] != 0: return - allArgs = ["/usr/bin/sbatch", ctx.work_path + "/job.slurm"] + allArgs = ("/usr/bin/docker run -h localhost --user 1001:65534 --rm -v /data/run/jobs/%s/:/data/ --network none kunkel/oer-worker /data/execute.sh" % ctx.id).split(" ") + print(" ".join(allArgs), file=sys.stderr) p = subprocess.Popen(allArgs, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ctx.work_path) + timeout = 1 + poll_period = 0.1 + p.poll() + while p.returncode is None and timeout > 0: + time.sleep(poll_period) + timeout -= poll_period + p.poll() + if timeout <= 0: + p.kill() # timed out + msgs,errs = p.communicate() retval = p.wait() errs = errs.decode("utf-8") msgs = msgs.decode("utf-8") - ctx.execute_result = (retval, errs, msgs) - - retval = ctx.get_file_content('job.exit') - errs = ctx.get_file_content('job.err') - msgs = ctx.get_file_content('job.out') - - print( (retval, errs, msgs), file=sys.stderr) - return retval, errs, msgs diff --git a/oer/exercise-formats/program/match-regex-parallel/script.js b/oer/exercise-formats/program/match-regex-parallel/script.js deleted file mode 100755 index 2c0638f..0000000 --- a/oer/exercise-formats/program/match-regex-parallel/script.js +++ /dev/null @@ -1,156 +0,0 @@ -$(document).ready(function () { - - response = {}; - - response.show = function (action, msg, output) { - console.log("show issued" + action + msg); - - html = ""; - - if (action == "test") { - - } else { - if (msg.data.grade == "PASS") { - html = ''; - $("#continue").prop( "disabled", false); - } else if (msg.data.grade == "FAIL") { - html = ''; - } else { - // assume test - //html = msg; - // a possible message that is generated yb the server to give tips? - } - } - - - console.log(output) - if ( output == "" ) { - output = " " - } - - if ( output != false) { - console.log("output is not false") - $("#output-wrapper").show(500); - $("#output").html(output); - } - - $("#response").hide().html(html).show(500); - - - $("#submit-test").prop( "disabled", false); - $("#submit-grade").prop( "disabled", false); - - } - - - job = {} - job.submit = function (action) { - - console.log("Test submission issued.."); - console.log( $("#c-code").val() ); - - submission = {"solution": cEditor.getValue(), "action": action, "slide": window.data.slide}; - submission_json = JSON.stringify(submission); - - console.log(submission_json) - - $.ajax({ - method: "POST", - url: "/api/rest/job/new/", - contentType: 'application/json', - data: submission_json - }) - .done(function( msg ) { - console.log("Job submitted: " + msg ); - console.log(msg); - - job_id = msg['id']; - - $("#job-control").show(500); - setTimeout(function(){ job.status(action, job_id); }, 1000); - - }); - }; - - - job_status_countdown = 5; - job_status_retries = 1; - job.status = function (action, job_id) { - - console.log(action) - - $("#collect-results-countdown").html("(retry in " + job_status_countdown +" s)"); - - if (job_status_countdown > 0) { - job_status_countdown--; - setTimeout(function(){ job.status(action, job_id); }, 1000); - return; - } - - - e = {"dummy": "dummy value"}; - json_data = JSON.stringify(e); - - $.ajax({ - method: "GET", - url: "/api/rest/job/" + job_id + "/", - contentType: 'application/json', - }) - .done(function( msg ) { - console.log("Status received: " + msg ); - console.log(msg); - - if ( msg.status == 'SUCCESS' ) { - $("#job-control").hide(500); - job_status_retries = 1; - response.show(action, msg, msg.data.output); - } else { - job_status_countdown = 5 * job_status_retries; - job_status_retries++; - //response.show(action, "processing...", false); - setTimeout(function(){ job.status(action, job_id); }, 1000); - } - - }); - - }; - - - $("#submit-test").click(function(event) { - $("#submit-test").prop( "disabled", true); - job.submit("test"); - }); - - $("#submit-grade").click(function(event) { - $("#submit-grade").prop( "disabled", true); - job.submit("grade"); - }); - - - $("#exercise-choices a.list-group-item").click(function(event) { - event.preventDefault() - //$("#submit-test").prop( "disabled", true); - //job.submit("test"); - - - target = event.target - - - if ( $(target).is('input') ) { - target = $(event.target).parent()[0] - } else { - // also check/uncheck when clicking surounding - } - - //if ( $(target).children("input").attr('type') == 'radio' ) { - // $(target).parent().children(".list-group-item-success").removeClass("list-group-item-success"); - //} - - console.log(target) - $(target).children("input").each(function () { this.checked = !this.checked; console.log(this) }); - //$(target).toggleClass("list-group-item-success"); - - }); - -}); - diff --git a/oer/exercise-formats/program/match-regex-parallel/script.js b/oer/exercise-formats/program/match-regex-parallel/script.js new file mode 120000 index 0000000..d806bd6 --- /dev/null +++ b/oer/exercise-formats/program/match-regex-parallel/script.js @@ -0,0 +1 @@ +/data/oer/exercise-formats/program/match-regex/script.js \ No newline at end of file diff --git a/oer/exercise-formats/program/match-regex-parallel/template-with-cancel.html b/oer/exercise-formats/program/match-regex-parallel/template-with-cancel.html new file mode 100644 index 0000000..ec4684f --- /dev/null +++ b/oer/exercise-formats/program/match-regex-parallel/template-with-cancel.html @@ -0,0 +1,56 @@ +{% extends "courses/course.html" %} +{% load staticfiles %} +{% load main_extras %} + + +{% block exercise_content %} +{{ slide.content |safe }} + +
+ + +{% endblock%} + + + +{% block exercise_buttons %} + + + + + + + +{% endblock %} + + +{% block exercise_script %} + +{% endblock %} diff --git a/oer/exercise-formats/program/match-regex-parallel/template.html b/oer/exercise-formats/program/match-regex-parallel/template.html index ec4684f..63b3917 100644 --- a/oer/exercise-formats/program/match-regex-parallel/template.html +++ b/oer/exercise-formats/program/match-regex-parallel/template.html @@ -23,31 +23,6 @@ var cEditor = CodeMirror.fromTextArea(document.getElementById("code"), { {% block exercise_buttons %} - - - - - {% endblock %} diff --git a/oer/exercise-formats/program/match-regex-parallel/test.js b/oer/exercise-formats/program/match-regex-parallel/test.js new file mode 100644 index 0000000..2c0638f --- /dev/null +++ b/oer/exercise-formats/program/match-regex-parallel/test.js @@ -0,0 +1,156 @@ +$(document).ready(function () { + + response = {}; + + response.show = function (action, msg, output) { + console.log("show issued" + action + msg); + + html = ""; + + if (action == "test") { + + } else { + if (msg.data.grade == "PASS") { + html = ''; + $("#continue").prop( "disabled", false); + } else if (msg.data.grade == "FAIL") { + html = ''; + } else { + // assume test + //html = msg; + // a possible message that is generated yb the server to give tips? + } + } + + + console.log(output) + if ( output == "" ) { + output = " " + } + + if ( output != false) { + console.log("output is not false") + $("#output-wrapper").show(500); + $("#output").html(output); + } + + $("#response").hide().html(html).show(500); + + + $("#submit-test").prop( "disabled", false); + $("#submit-grade").prop( "disabled", false); + + } + + + job = {} + job.submit = function (action) { + + console.log("Test submission issued.."); + console.log( $("#c-code").val() ); + + submission = {"solution": cEditor.getValue(), "action": action, "slide": window.data.slide}; + submission_json = JSON.stringify(submission); + + console.log(submission_json) + + $.ajax({ + method: "POST", + url: "/api/rest/job/new/", + contentType: 'application/json', + data: submission_json + }) + .done(function( msg ) { + console.log("Job submitted: " + msg ); + console.log(msg); + + job_id = msg['id']; + + $("#job-control").show(500); + setTimeout(function(){ job.status(action, job_id); }, 1000); + + }); + }; + + + job_status_countdown = 5; + job_status_retries = 1; + job.status = function (action, job_id) { + + console.log(action) + + $("#collect-results-countdown").html("(retry in " + job_status_countdown +" s)"); + + if (job_status_countdown > 0) { + job_status_countdown--; + setTimeout(function(){ job.status(action, job_id); }, 1000); + return; + } + + + e = {"dummy": "dummy value"}; + json_data = JSON.stringify(e); + + $.ajax({ + method: "GET", + url: "/api/rest/job/" + job_id + "/", + contentType: 'application/json', + }) + .done(function( msg ) { + console.log("Status received: " + msg ); + console.log(msg); + + if ( msg.status == 'SUCCESS' ) { + $("#job-control").hide(500); + job_status_retries = 1; + response.show(action, msg, msg.data.output); + } else { + job_status_countdown = 5 * job_status_retries; + job_status_retries++; + //response.show(action, "processing...", false); + setTimeout(function(){ job.status(action, job_id); }, 1000); + } + + }); + + }; + + + $("#submit-test").click(function(event) { + $("#submit-test").prop( "disabled", true); + job.submit("test"); + }); + + $("#submit-grade").click(function(event) { + $("#submit-grade").prop( "disabled", true); + job.submit("grade"); + }); + + + $("#exercise-choices a.list-group-item").click(function(event) { + event.preventDefault() + //$("#submit-test").prop( "disabled", true); + //job.submit("test"); + + + target = event.target + + + if ( $(target).is('input') ) { + target = $(event.target).parent()[0] + } else { + // also check/uncheck when clicking surounding + } + + //if ( $(target).children("input").attr('type') == 'radio' ) { + // $(target).parent().children(".list-group-item-success").removeClass("list-group-item-success"); + //} + + console.log(target) + $(target).children("input").each(function () { this.checked = !this.checked; console.log(this) }); + //$(target).toggleClass("list-group-item-success"); + + }); + +}); + diff --git a/oer/exercise-formats/program/match-regex/script.js b/oer/exercise-formats/program/match-regex/script.js index 2ebcad7..dd7fd55 100755 --- a/oer/exercise-formats/program/match-regex/script.js +++ b/oer/exercise-formats/program/match-regex/script.js @@ -3,7 +3,7 @@ $(document).ready(function () { response = {}; response.show = function (type, msg, output) { - //console.log("show issued" + type + msg); + //console.log("show issued " + type + " " + msg); html = ""; @@ -25,18 +25,14 @@ $(document).ready(function () { output = " " } - if ( output != false) { - //console.log("output is not false") - $("#output-wrapper").show(500); - $("#output").html(output); - } + //console.log("output is not false") + $("#output-wrapper").show(500); + $("#output").html(output); $("#response").hide().html(html).show(500); - - $("#submit-test").prop( "disabled", false); - $("#submit-grade").prop( "disabled", false); - + //$("#submit-test").prop( "disabled", false); + //$("#submit-grade").prop( "disabled", false); } diff --git a/oer/exercise-formats/program/match-regex-multifile/ExerciseHandler.py b/oer/exercise-formats/program/old/match-regex-multifile/ExerciseHandler.py similarity index 100% rename from oer/exercise-formats/program/match-regex-multifile/ExerciseHandler.py rename to oer/exercise-formats/program/old/match-regex-multifile/ExerciseHandler.py diff --git a/oer/exercise-formats/program/match-regex-multifile/controller.py b/oer/exercise-formats/program/old/match-regex-multifile/controller.py similarity index 100% rename from oer/exercise-formats/program/match-regex-multifile/controller.py rename to oer/exercise-formats/program/old/match-regex-multifile/controller.py diff --git a/oer/exercise-formats/program/match-regex-multifile/script.js b/oer/exercise-formats/program/old/match-regex-multifile/script.js similarity index 100% rename from oer/exercise-formats/program/match-regex-multifile/script.js rename to oer/exercise-formats/program/old/match-regex-multifile/script.js diff --git a/oer/exercise-formats/program/match-regex-multifile/styles.css b/oer/exercise-formats/program/old/match-regex-multifile/styles.css similarity index 100% rename from oer/exercise-formats/program/match-regex-multifile/styles.css rename to oer/exercise-formats/program/old/match-regex-multifile/styles.css diff --git a/oer/exercise-formats/program/match-regex-multifile/template.html b/oer/exercise-formats/program/old/match-regex-multifile/template.html similarity index 100% rename from oer/exercise-formats/program/match-regex-multifile/template.html rename to oer/exercise-formats/program/old/match-regex-multifile/template.html diff --git a/oer/exercise-formats/program/scriptgrade-multifile/ExerciseHandler.py b/oer/exercise-formats/program/old/scriptgrade-multifile/ExerciseHandler.py similarity index 100% rename from oer/exercise-formats/program/scriptgrade-multifile/ExerciseHandler.py rename to oer/exercise-formats/program/old/scriptgrade-multifile/ExerciseHandler.py diff --git a/oer/exercise-formats/program/scriptgrade-parallel/ExerciseHandler.py b/oer/exercise-formats/program/scriptgrade-parallel/ExerciseHandler.py deleted file mode 100644 index 8caba65..0000000 --- a/oer/exercise-formats/program/scriptgrade-parallel/ExerciseHandler.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -print("Handler program/scriptgrade loaded!") - - -class ExerciseHandler(object): - def __init__(self): - print("ExerciseHandler program/scriptgrade") diff --git a/oer/exercise-formats/program/scriptgrade/controller.py b/oer/exercise-formats/program/scriptgrade/controller.py index 5da88c8..1230822 100644 --- a/oer/exercise-formats/program/scriptgrade/controller.py +++ b/oer/exercise-formats/program/scriptgrade/controller.py @@ -57,7 +57,7 @@ def grade(ctx): # if build failed, return early and set grade to FAIL if ctx.build_result[0] != 0: return 'FAIL' - allArgs = ['./test.sh'] + allArgs = ("/usr/bin/docker run -h oer-worker --user 1001:65534 --rm -v /data/run/jobs/%s/:/data/ --network none kunkel/oer-worker /data/test.sh" % ctx.id).split(" ") print(" ".join(allArgs), file=sys.stderr) # start subprocess in with work_path as cwd