This commit is contained in:
Julian M. Kunkel 2018-05-06 14:21:42 +01:00
parent 43a0fa6c4f
commit f225d5ebef
23 changed files with 236 additions and 757 deletions

View File

@ -0,0 +1,2 @@
#!/bin/bash
mpiexec -n 2 ./program

View File

@ -1,3 +0,0 @@
#!/bin/sh
#SBATCH -N 2
mpiexec program

View File

@ -0,0 +1,2 @@
#!/bin/bash
mpiexec -n 2 ./program

View File

@ -1,3 +0,0 @@
#!/bin/sh
#SBATCH -n 4
mpiexec program

View File

@ -1,541 +0,0 @@
let SessionLoad = 1
if &cp | set nocp | endif
let s:cpo_save=&cpo
set cpo&vim
nmap gx <Plug>NetrwBrowseX
nnoremap <silent> <Plug>NetrwBrowseX :call netrw#NetrwBrowseX(expand("<cfile>"),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("<sfile>: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("<sfile>: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 :

View File

@ -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

View File

@ -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 = '<div class="alert alert-success" role="alert"><strong>Great!</strong> Your solution is correct.<br/></div>';
$("#continue").prop( "disabled", false);
} else if (msg.data.grade == "FAIL") {
html = '<div class="alert alert-danger" role="alert"><strong>Sorry!</strong> That is not correct.<br/></div>';
} else {
// assume test
//html = msg;
// a possible message that is generated yb the server to give tips?
}
}
console.log(output)
if ( output == "" ) {
output = "&nbsp;"
}
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");
});
});

View File

@ -0,0 +1 @@
/data/oer/exercise-formats/program/match-regex/script.js

View File

@ -0,0 +1,56 @@
{% extends "courses/course.html" %}
{% load staticfiles %}
{% load main_extras %}
{% block exercise_content %}
{{ slide.content |safe }}
<div id="code-editor"><textarea name="sol" id="code">{{ slide_data.code |safe }}</textarea></div>
<script>
var cEditor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
viewportMargin: Infinity,
matchBrackets: true,
mode: "text/x-csrc",
});
</script>
{% endblock%}
{% block exercise_buttons %}
<input type="button" name="test" id="submit-test" value="Execute" class="btn btn-primary" />
<input type="button" name="submit" id="submit-grade" value="Submit Solution" class="btn btn-default" />
<div id="job-control" style="display: none; margin-top: 1em; marign-bottom: 1em;">
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel Job</button>
<button type="submit" class="btn btn-info btn-xs" disabled><i class="glyphicon glyphicon-refresh"></i> Collect results <span id="collect-results-countdown"></span></button>
</div>
<!--
</br>
</br>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-refresh"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-inbox"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-download-alt"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-cloud-download"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-save"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-copy"></i> Collect results</button>
</br>
</br>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove-sign"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove-circle"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-off"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i> Cancel Job</button>
-->
{% endblock %}
{% block exercise_script %}
<script type="text/javascript" src="{% static 'generated_exercises' %}/{{ slide.slide_type }}/script.js"></script>
{% endblock %}

View File

@ -23,31 +23,6 @@ var cEditor = CodeMirror.fromTextArea(document.getElementById("code"), {
{% block exercise_buttons %}
<input type="button" name="test" id="submit-test" value="Execute" class="btn btn-primary" />
<input type="button" name="submit" id="submit-grade" value="Submit Solution" class="btn btn-default" />
<div id="job-control" style="display: none; margin-top: 1em; marign-bottom: 1em;">
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel Job</button>
<button type="submit" class="btn btn-info btn-xs" disabled><i class="glyphicon glyphicon-refresh"></i> Collect results <span id="collect-results-countdown"></span></button>
</div>
<!--
</br>
</br>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-refresh"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-inbox"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-download-alt"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-cloud-download"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-save"></i> Collect results</button>
<button type="submit" class="btn btn-info btn-xs"><i class="glyphicon glyphicon-copy"></i> Collect results</button>
</br>
</br>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove-sign"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove-circle"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-off"></i> Cancel Job</button>
<button type="submit" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i> Cancel Job</button>
-->
{% endblock %}

View File

@ -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 = '<div class="alert alert-success" role="alert"><strong>Great!</strong> Your solution is correct.<br/></div>';
$("#continue").prop( "disabled", false);
} else if (msg.data.grade == "FAIL") {
html = '<div class="alert alert-danger" role="alert"><strong>Sorry!</strong> That is not correct.<br/></div>';
} else {
// assume test
//html = msg;
// a possible message that is generated yb the server to give tips?
}
}
console.log(output)
if ( output == "" ) {
output = "&nbsp;"
}
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");
});
});

View File

@ -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 = "&nbsp;"
}
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);
}

View File

@ -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")

View File

@ -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