This commit is contained in:
Julian M. Kunkel 2018-05-06 10:20:32 +01:00
parent 1a0c5af7f7
commit d82609737d
14 changed files with 63 additions and 94 deletions

0
oer/exercise-formats/choice/multiple/script.js Normal file → Executable file
View File

0
oer/exercise-formats/input/text/script.js Normal file → Executable file
View File

View File

View File

2
oer/exercise-formats/program/match-regex/controller.py Normal file → Executable file
View File

@ -63,9 +63,7 @@ def grade(ctx):
return 'FAIL'
def response(ctx):
output = ""
if ctx.build_result[0] != 0:
output = ctx.build_result[1]

0
oer/exercise-formats/program/match-regex/script.js Normal file → Executable file
View File

0
oer/exercise-formats/program/scriptgrade/script.js Normal file → Executable file
View File

0
oer/exercise-formats/text/html/script.js Normal file → Executable file
View File

View File

@ -14,6 +14,8 @@
.sep { color: silver; margin: 0.3em; }
</style>
<a href="/privacy">Privacy</a>
<span class="sep">|</span>
<a href="https://hps.vi4io.org/impressum">Impressum</a>
<span class="sep">|</span>
<a href="https://hps.vi4io.org/research/projects/hamburg/icp">Contact</a>

View File

@ -34,6 +34,10 @@ def attribution(request):
data = {}
return render(request, 'frontend/attribution.html', data)
def privacy(request):
data = {}
return render(request, 'frontend/privacy.html', data)
def dashboard(request):
# only registered users can see their statistics
if not request.user.is_authenticated:

View File

@ -29,6 +29,7 @@ urlpatterns = [
url(r'^dashboard/$', frontend.views.dashboard, name='dashboard'),
url(r'^settings/$', frontend.views.settings, name='settings'),
url(r'^attribution/$', frontend.views.attribution, name='attribution'),
url(r'^privacy/$', frontend.views.privacy, name='privacy'),
# Courses
url(r'^courses/', include('courses.urls', namespace='courses')),

View File

@ -27,6 +27,7 @@ import sys
import os
import pprint
import re
import os.path
from courses.models import Course
from courses.models import Section
@ -34,14 +35,26 @@ from courses.models import Slide
from courses.models import UserCourse
from courses.models import UserSolution
from runner.tasks import compile_and_run
import json
def local_execute(dic):
print("LOCAL EXECUTE")
print(dic)
return {"id" : 100}
#print("LOCAL EXECUTE")
id = 100
ret = compile_and_run(id, dic)
print(ret, file=sys.stderr)
return {"status" : 'SUCCESS', "id" : id, "result": ret}
def local_execute_result(id):
print("Retrieving: " + id)
return {"status" : 201, "result": {"output" : False, "grade" : "PASS"}}
#return {"status" : 201, "result": {"output" : False, "grade" : "PASS"}}
file = "/data/run/jobs/%s/job.json" % (id)
print("Retrieving: " + file)
if os.path.isfile(file):
with open(file) as json_data:
d = json.load(json_data)
return {"status" : 'SUCCESS', "result": d["response"]}
else:
return {"status" : 0, "result": {"output" : False}}
# helpers
class JSONResponse(HttpResponse):
@ -178,7 +191,6 @@ def job_status(request, jid):
#data = JSONParser().parse(json_docs)
return JSONResponse(data)
return HttpResponse("huh", status=401)

View File

@ -1,34 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from runner.celery import app
#from runner.celery import app
import subprocess
import os
import sys
import shutil
import json
import importlib.machinery
# To conserve resources consider using the ignore result decorator, when the result is not used by someone else
#@app.task(ignore_result=True)
###############################################################################
# Settings
###############################################################################
WORK_DIR = os.path.expanduser(os.environ["WORKER_DIR"])
OER_FORMATS_PATH = os.path.expanduser(os.environ["WORKER_OER_DIR"] + "/exercise-formats/")
###############################################################################
WORK_DIR = "/data/run/jobs"
OER_FORMATS_PATH = "/data/oer/exercise-formats/"
def load_handler(path):
handler = {'name': None, 'loader': None, 'mod': None}
handler = {'name': None, 'loader': None, 'mod': None}
#print(path, file=sys.stderr)
for root, dirs, files in os.walk(path):
#print(root, file=sys.stderr)
#print(dirs, file=sys.stderr)
#print(files, file=sys.stderr)
if 'controller.py' in files:
@ -66,8 +55,8 @@ class Job(object):
"""
def __init__(self, job, celery_task=None):
print("Job.__init__()", file=sys.stderr)
def __init__(self, job):
#print("Job.__init__()", file=sys.stderr)
self.data = job
self.work_path = WORK_DIR + '/' + str(job['_id']) + '/'
self.handler_format = {'name': None, 'loader': None, 'mod': None}
@ -78,14 +67,6 @@ class Job(object):
self.grade_result = 'FAIL'
self.response_data = {}
# allow controllers to manipulate celery task
# e.g. to set meta data after submitting slurm jobs
self.celery_task = celery_task
def import_handlers(self):
print("Job.init_handlers()", file=sys.stderr)
@ -101,8 +82,7 @@ class Job(object):
def extract(self):
print("Job.extract()", file=sys.stderr)
#print("Job.extract()", file=sys.stderr)
# creates workdir and files
print(self.data['source_path'], file=sys.stderr)
print(self.work_path, file=sys.stderr)
@ -121,14 +101,6 @@ class Job(object):
source.close()
pass
def build(self):
print("Job.build()", file=sys.stderr)
@ -208,11 +180,8 @@ class Job(object):
fp = open(self.jobfile, 'w')
json.dump({"job": self.data, "response": self.response_data}, fp)
fp.close()
# into mongodb
def get_file_content(self, filename):
try:
with open(self.work_path + '/' + filename, 'r') as f:
@ -228,36 +197,29 @@ class Job(object):
@app.task(time_limit=20)
def timelimited_task():
try:
return do_work()
except SoftTimeLimitExceeded:
cleanup_in_a_hurry()
@app.task
def compile():
return True
#@app.task(time_limit=20)
#def timelimited_task():
# try:
# return do_work()
# except SoftTimeLimitExceeded:
# cleanup_in_a_hurry()
#
#@app.task
#def compile():
# return True
@app.task(bind=True)
def compile_and_run(self, data):
print(data, file=sys.stderr)
print(self.request.id, file=sys.stderr)
print(data['type'], file=sys.stderr)
print(data['action'], file=sys.stderr)
print(data['source_path'], file=sys.stderr)
data['_id'] = self.request.id
#@app.task(bind=True)
def compile_and_run(id, data):
#print(data, file=sys.stderr)
#print(data['type'], file=sys.stderr)
#print(data['action'], file=sys.stderr)
#print(data['source_path'], file=sys.stderr)
data['_id'] = id
# create job object and call the different handlers
j = Job(data, celery_task=self)
j = Job(data)
j.import_handlers()
if data['action'] not in ["quiz"]:
j.extract()
j.build()
@ -268,20 +230,10 @@ def compile_and_run(self, data):
if data['action'] in ["grade", "quiz"]:
j.grade()
print("Result prepare")
#print("Result prepare")
ret = j.response()
j.response_data = ret
j.store_result()
print("Result sent!")
#print("Result sent!")
return ret
# self.update_state(state='SUBMITTED TO SLURM', meta={})
# Convienence task definitions for programming assignments
@app.task
def compile_run_and_grade():
# start the celeryropriete subtasks
return True