diff --git a/oer/exercise-formats/choice/multiple/script.js b/oer/exercise-formats/choice/multiple/script.js index 8ac0444..f85116f 100755 --- a/oer/exercise-formats/choice/multiple/script.js +++ b/oer/exercise-formats/choice/multiple/script.js @@ -61,7 +61,7 @@ $(document).ready(function () { submission = {"solution": sol, "slide": window.data.slide, "action": "quiz"}; submission_json = JSON.stringify(submission); - console.log(submission_json) + //console.log(submission_json) $.ajax({ method: "POST", @@ -72,45 +72,16 @@ $(document).ready(function () { .done(function( msg ) { console.log("Job submitted: " + msg ); console.log(msg); - - job_id = msg['id']; - - // really timeout? - // how about handling this directly? - setTimeout(function(){ job.status(action, job_id); }, 1000); - - }); - }; - - job.status = function (type, job_id) { - - console.log(type); - - e = {"blub": "hm"}; - 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' ) { response.show(type, msg, msg.data.output); } else { response.show(type, "processing...", false); setTimeout(function(){ job.status(type, job_id); }, 3000); } - - }); - }; - $("#submit-grade").click(function(event) { + $("#submit-grade").click(function(event) { $("#submit-grade").prop( "disabled", true); job.submit("grade"); }); @@ -123,11 +94,11 @@ $(document).ready(function () { $("#exercise-choices a.list-group-item").click(function(event) { event.preventDefault() //$("#submit-test").prop( "disabled", true); - //job.submit("test"); + //job.submit("test"); + - target = event.target - + if ( $(target).is('input') ) { target = $(event.target).parent()[0] @@ -135,7 +106,7 @@ $(document).ready(function () { // 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"); //} @@ -144,9 +115,8 @@ $(document).ready(function () { $(target).children("input").each(function () { this.checked = !this.checked; console.log(this) }); //$(target).toggleClass("list-group-item-userchoice"); - + }); }); - diff --git a/oer/exercise-formats/program/match-regex-parallel/controller.py b/oer/exercise-formats/program/match-regex-parallel/controller.py index 5bb5f40..c26a89b 100644 --- a/oer/exercise-formats/program/match-regex-parallel/controller.py +++ b/oer/exercise-formats/program/match-regex-parallel/controller.py @@ -21,7 +21,7 @@ def build(ctx): # start subprocess in with work_path as cwd p = subprocess.Popen(allArgs, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ctx.work_path) msgs,errs = p.communicate() - retval = p.wait() + retval = p.wait() errs = errs.decode("utf-8") msgs = msgs.decode("utf-8") @@ -41,25 +41,23 @@ def execute(ctx): p = subprocess.Popen(allArgs, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ctx.work_path) msgs,errs = p.communicate() - retval = p.wait() + retval = p.wait() errs = errs.decode("utf-8") msgs = msgs.decode("utf-8") - + ctx.execute_result = (retval, errs, msgs) + #ctx.celery_task.update_state(state='SUBMITTED TO SLURM', meta=response(ctx)) - - ctx.celery_task.update_state(state='SUBMITTED TO SLURM', meta=response(ctx)) - - print("parallel execute(), before sleep", file=sys.stderr) - time.sleep(20) - print("parallel execute(), after sleep", file=sys.stderr) + #print("parallel execute(), before sleep", file=sys.stderr) + #time.sleep(20) + #print("parallel execute(), after sleep", file=sys.stderr) 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 @@ -84,10 +82,10 @@ def grade(ctx): else: return 'FAIL' - + def response(ctx): - + output = "" if ctx.build_result[0] != 0: output = ctx.build_result[1] diff --git a/oer/exercise-formats/program/match-regex/controller.py b/oer/exercise-formats/program/match-regex/controller.py index 81c6cb2..280a388 100755 --- a/oer/exercise-formats/program/match-regex/controller.py +++ b/oer/exercise-formats/program/match-regex/controller.py @@ -10,6 +10,7 @@ import sys import subprocess import re +import time def build(ctx): @@ -36,6 +37,16 @@ def execute(ctx): allArgs = [ctx.programfile] 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() diff --git a/oer/exercise-formats/program/match-regex/script.js b/oer/exercise-formats/program/match-regex/script.js index 208f30e..b5449b1 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 = ""; @@ -22,17 +22,17 @@ $(document).ready(function () { } } - + console.log(output) if ( output == "" ) { output = " " } if ( output != false) { - console.log("output is not false") + //console.log("output is not false") $("#output-wrapper").show(500); $("#output").html(output); - } + } $("#response").hide().html(html).show(500); @@ -46,13 +46,13 @@ $(document).ready(function () { job = {} job.submit = function (action) { - console.log("Test submission issued.."); - console.log( $("#c-code").val() ); + //console.log("Test submission issued.."); + //console.log( $("#c-code").val() ); submission = {"solution": cEditor.getValue(), "cmd": "run.sh", "action": action, "slide": window.data.slide}; submission_json = JSON.stringify(submission); - console.log(submission_json) + //console.log(submission_json) $.ajax({ method: "POST", @@ -61,18 +61,17 @@ $(document).ready(function () { data: submission_json }) .done(function( msg ) { - console.log("Job submitted: " + msg ); - console.log(msg); + //console.log("Job submitted: " + msg ); + //console.log(msg); job_id = msg['id']; - setTimeout(function(){ job.status(action, job_id); }, 1000); + setTimeout(function(){ job.status(action, job_id); }, 100); - }); + }); }; job.status = function (type, job_id) { - - console.log(type) + //console.log(type) e = {"blub": "hm"}; json_data = JSON.stringify(e); @@ -90,7 +89,7 @@ $(document).ready(function () { response.show(type, msg, msg.data.output); } else { response.show(type, "processing...", false); - setTimeout(function(){ job.status(type, job_id); }, 3000); + setTimeout(function(){ job.status(type, job_id); }, 1000); } }); @@ -100,10 +99,10 @@ $(document).ready(function () { $("#submit-test").click(function(event) { $("#submit-test").prop( "disabled", true); - job.submit("test"); + job.submit("test"); }); - $("#submit-grade").click(function(event) { + $("#submit-grade").click(function(event) { $("#submit-grade").prop( "disabled", true); job.submit("grade"); }); @@ -112,11 +111,11 @@ $(document).ready(function () { $("#exercise-choices a.list-group-item").click(function(event) { event.preventDefault() //$("#submit-test").prop( "disabled", true); - //job.submit("test"); + //job.submit("test"); + - target = event.target - + if ( $(target).is('input') ) { target = $(event.target).parent()[0] @@ -135,4 +134,3 @@ $(document).ready(function () { }); }); - diff --git a/oer/exercise-formats/program/scriptgrade/controller.py b/oer/exercise-formats/program/scriptgrade/controller.py index 6e69a06..bb49c8e 100644 --- a/oer/exercise-formats/program/scriptgrade/controller.py +++ b/oer/exercise-formats/program/scriptgrade/controller.py @@ -9,6 +9,7 @@ import sys import subprocess import re +import time def build(ctx): # Add filenames @@ -18,7 +19,7 @@ def build(ctx): # start subprocess in with work_path as cwd p = subprocess.Popen(allArgs, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=ctx.work_path) msgs,errs = p.communicate() - retval = p.wait() + retval = p.wait() errs = errs.decode("utf-8") msgs = msgs.decode("utf-8") @@ -32,6 +33,16 @@ def execute(ctx): # start subprocess in with work_path as cwd 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() @@ -42,7 +53,7 @@ def execute(ctx): def grade(ctx): - print("GRADING!!", file=sys.stderr) + #print("GRADING!!", file=sys.stderr) # if build failed, return early and set grade to FAIL if ctx.build_result[0] != 0: @@ -55,12 +66,22 @@ def grade(ctx): # start subprocess in with work_path as cwd 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() + retval = p.wait() errs = errs.decode("utf-8") msgs = msgs.decode("utf-8") - + ctx.execute_result = (retval, errs, msgs) @@ -89,4 +110,3 @@ def response(ctx): grade = ctx.grade_result msg = "" return {'output': output, 'grade': grade, 'msg': msg, 'data': None} - diff --git a/src/frontend/templates/frontend/attribution.html b/src/frontend/templates/frontend/attribution.html index 73f5b6f..0f0df22 100644 --- a/src/frontend/templates/frontend/attribution.html +++ b/src/frontend/templates/frontend/attribution.html @@ -1,73 +1,6 @@ {% load staticfiles %} -{% load cookielaw_tags %} - - - -
- - - - - - - - -In order to ensure a distraction free learning expierence references to work by third parties was ommited where possible. @@ -85,83 +18,6 @@ Please see the project details here.
- - - - - -The colorful header on top of the e.g. the entry page uses artworks created by multiple artists from the Noun Project:
- -Several open source software projects enable the platform to operate. This section is dedicated to acknowledge the most important.
@@ -170,14 +26,10 @@