Skip to content
Snippets Groups Projects
Commit bafbf14b authored by tuhe's avatar tuhe
Browse files

updates

parent cdec5876
No related branches found
No related tags found
No related merge requests found
Showing
with 253 additions and 191 deletions
...@@ -4,6 +4,7 @@ cd ~/Autolab && bundle exec rails s -p 8000 --binding=0.0.0.0 ...@@ -4,6 +4,7 @@ cd ~/Autolab && bundle exec rails s -p 8000 --binding=0.0.0.0
To remove my shitty image: To remove my shitty image:
docker rmi tango_python_tue docker rmi tango_python_tue
""" """
import inspect
from zipfile import ZipFile from zipfile import ZipFile
import os import os
from os.path import basename from os.path import basename
...@@ -11,6 +12,10 @@ import os ...@@ -11,6 +12,10 @@ import os
import shutil import shutil
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
import glob import glob
import pickle
from unitgrade2.unitgrade2 import Report
import inspect
from unitgrade_private2 import docker_helpers
COURSES_BASE = "/home/tuhe/Autolab/courses/AutoPopulated" COURSES_BASE = "/home/tuhe/Autolab/courses/AutoPopulated"
TEMPLATE_BASE = "/home/tuhe/Documents/unitgrade_private/autolab/lab_template" TEMPLATE_BASE = "/home/tuhe/Documents/unitgrade_private/autolab/lab_template"
...@@ -39,7 +44,6 @@ def jj_handout(source, dest, data): ...@@ -39,7 +44,6 @@ def jj_handout(source, dest, data):
def zipFilesInDir(dirName, zipFileName, filter): def zipFilesInDir(dirName, zipFileName, filter):
# create a ZipFile object
with ZipFile(zipFileName, 'w') as zipObj: with ZipFile(zipFileName, 'w') as zipObj:
# Iterate over all the files in directory # Iterate over all the files in directory
for folderName, subfolders, filenames in os.walk(dirName): for folderName, subfolders, filenames in os.walk(dirName):
...@@ -50,43 +54,98 @@ def zipFilesInDir(dirName, zipFileName, filter): ...@@ -50,43 +54,98 @@ def zipFilesInDir(dirName, zipFileName, filter):
# Add file to zip # Add file to zip
zipObj.write(filePath, basename(filePath)) zipObj.write(filePath, basename(filePath))
def paths2report(base_path, report_file):
mod = ".".join(os.path.relpath(report_file[:-3], base_path).split(os.sep))
# f2 = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101"
# spec1 = importlib.util.spec_from_file_location("cs101", f2)
# cs101 = importlib.util.module_from_spec(spec1)
# spec1.loader.exec_module(cs101)
from importlib.machinery import SourceFileLoader
foo = SourceFileLoader(mod, report_file).load_module()
# return foo.Report1
# spec = importlib.util.spec_from_file_location(mod, report_file)
# foo = importlib.util.module_from_spec(spec)
# spec.loader.exec_module(foo)
for name, obj in inspect.getmembers(foo):
if inspect.isclass(obj): # and obj.__module__ == foo:
if obj.__module__ == foo.__name__: # and issubclass(obj, Report):
if issubclass(obj, Report):
report = getattr(foo, name)
return report
return None
def run_relative(file, base):
relative = os.path.relpath(file, base)
mod = os.path.normpath(relative)[:-3].split(os.sep)
os.system(f"cd {base} && python -m {'.'.join(mod)}")
import inspect
# class Example:
# @property
# def title(self):
# stack = inspect.stack()
# return stack[1].function.__doc__
# @title.setter
# def title(self, value):
# stack = inspect.stack()
# stack[1].function.__doc__ = value
# # self._title = value
#
# def myfun(self):
# self.title = 234
# self.title
#
# return 3
def deploy_assignment(base_name): def deploy_assignment(base_name):
docker_build_image()
# Ok so what should go on here? docker_build_image()
LAB_DEST = os.path.join(COURSES_BASE, base_name) LAB_DEST = os.path.join(COURSES_BASE, base_name)
STUDENT_HANDOUT_DIR = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101"
INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1_grade.py"
# STUDENT_TOKEN_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101"
from cs101.report1 import Report1 # The instructors report class. INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1_grade.py"
StudentReportClass = Report1.__qualname__ + "_handin.token" INSTRUCTOR_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor"
import inspect
# inspect.getfile(Report1.pack_imports[0])
m = Report1.pack_imports[0]
root, relative = Report1()._import_base_relative()
STUDENT_BASE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students"
STUDENT_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101/report1_grade.py"
z = 234 # STUDENT_HANDOUT_DIR = os.path.dirname(STUDENT_GRADE_FILE) #"/home/tuhe/Documents/unitgrade_private/examples/example_simplest/students/cs101"
# INSTRUCTOR_GRADE_FILE = "/home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1.py"
# Make instructor token file.
# Get the instructor result file.
run_relative(INSTRUCTOR_GRADE_FILE, INSTRUCTOR_BASE)
f = glob.glob(os.path.dirname(INSTRUCTOR_GRADE_FILE) + "/*.token")[0]
with open(f, 'rb') as f:
res = pickle.load(f)
# Now we have the instructor token file. Let's get the student token file.
problems = [dict(name='Total', description='', max_score=res['total'][1], optional='false')]
for k, q in res['details'].items():
problems.append(dict(name=q['title'], description='', max_score=q['possible'], optional='true'))
print(problems)
sc = [('Total', res['total'][0])] + [(q['title'], q['obtained']) for k, q in res['details'].items()]
ss = ", ".join( [f'"{t}": {s}' for t, s in sc] )
scores = '{"scores": {' + ss + '}}'
print(scores)
# Quickly make student .token file to upload: # Quickly make student .token file to upload:
# os.system(f"cd {os.path.dirname(STUDENT_HANDOUT_DIR)} && python -m cs101.{os.path.basename(INSTRUCTOR_GRADE_FILE)[:-3]}") # os.system(f"cd {os.path.dirname(STUDENT_HANDOUT_DIR)} && python -m cs101.{os.path.basename(INSTRUCTOR_GRADE_FILE)[:-3]}")
os.system(f"cd {STUDENT_HANDOUT_DIR} && python {os.path.basename(INSTRUCTOR_GRADE_FILE)}") # os.system(f"cd {STUDENT_HANDOUT_DIR} && python {os.path.basename(INSTRUCTOR_GRADE_FILE)}")
# handin_filename = os.path.basename(STUDENT_TOKEN_FILE)
STUDENT_TOKEN_FILE = glob.glob(STUDENT_HANDOUT_DIR + "/*.token")[0] run_relative(STUDENT_GRADE_FILE, STUDENT_BASE)
STUDENT_TOKEN_FILE = glob.glob(os.path.dirname(STUDENT_GRADE_FILE) + "/*.token")[0]
tname = os.path.basename(STUDENT_TOKEN_FILE) handin_filename = os.path.basename( STUDENT_TOKEN_FILE)
for _ in range(3): for _ in range(3):
tname = tname[:tname.rfind("_")] handin_filename = handin_filename[:handin_filename.rfind("_")]
tname += ".token" handin_filename += ".token"
print("> Name of handin file", tname)
# Take student handout and unzip it. print("> Name of handin file", handin_filename)
# Take student token file, unzip it and merge files.
# This is the directory which is going to be handed out.
if os.path.exists(LAB_DEST): if os.path.exists(LAB_DEST):
shutil.rmtree(LAB_DEST) shutil.rmtree(LAB_DEST)
os.mkdir(LAB_DEST) os.mkdir(LAB_DEST)
...@@ -94,61 +153,45 @@ def deploy_assignment(base_name): ...@@ -94,61 +153,45 @@ def deploy_assignment(base_name):
# Make the handout directory. # Make the handout directory.
# Start in the src directory. You should make the handout files first. # Start in the src directory. You should make the handout files first.
# jj("a", "b", data={}) os.mkdir(LAB_DEST + "/src")
src_dest = LAB_DEST + "/src"
# src_source = TEMPLATE_BASE + "/src"
os.mkdir(src_dest)
# unitgrade-docker
from unitgrade_private2 import docker_helpers
INSTRUCTOR_REPORT_FILE = INSTRUCTOR_GRADE_FILE[:-9] + ".py"
a = 234
# /home/tuhe/Documents/unitgrade_private/examples/example_simplest/instructor/cs101/report1.py"
data = { data = {
'base_name': base_name, 'base_name': base_name,
'nice_name': base_name + "please", # 'nice_name': base_name + "please",
# 'autograde_image': 'autograde_image', 'display_name': paths2report(INSTRUCTOR_BASE, INSTRUCTOR_REPORT_FILE).title,
'handin_filename': handin_filename,
'autograde_image': 'tango_python_tue', 'autograde_image': 'tango_python_tue',
'src_files_to_handout': ['driver_python.py','student_sources.zip', tname, os.path.basename(docker_helpers.__file__), 'src_files_to_handout': ['driver_python.py', 'student_sources.zip', handin_filename, os.path.basename(docker_helpers.__file__),
os.path.basename(INSTRUCTOR_GRADE_FILE)], # Remove tname later; it is the upload. os.path.basename(INSTRUCTOR_GRADE_FILE)], # Remove tname later; it is the upload.
'handin_filename': 'hello3.c', # the student token file.
'student_token_file': tname,
'instructor_grade_file': os.path.basename(INSTRUCTOR_GRADE_FILE), 'instructor_grade_file': os.path.basename(INSTRUCTOR_GRADE_FILE),
'grade_file_relative_destination': relative, 'grade_file_relative_destination': os.path.relpath(INSTRUCTOR_GRADE_FILE, INSTRUCTOR_BASE),
'problems': problems,
} }
# shutil.copyfile(TEMPLATE_BASE + "/hello.yml", f"{LAB_DEST}/{base_name}.yml") # shutil.copyfile(TEMPLATE_BASE + "/hello.yml", f"{LAB_DEST}/{base_name}.yml")
jj_handout(TEMPLATE_BASE + "/src/README", LAB_DEST + "/src/README", data) jj_handout(TEMPLATE_BASE + "/src/README", LAB_DEST + "/src/README", data)
jj_handout(TEMPLATE_BASE + "/src/driver_python.py", LAB_DEST + "/src/driver_python.py", data) jj_handout(TEMPLATE_BASE + "/src/driver_python.py", LAB_DEST + "/src/driver_python.py", data)
jj_handout(TEMPLATE_BASE + "/src/hello.c", LAB_DEST + "/src/hello3.c",data)
jj_handout(TEMPLATE_BASE + "/src/Makefile", LAB_DEST + "/src/Makefile",data) jj_handout(TEMPLATE_BASE + "/src/Makefile", LAB_DEST + "/src/Makefile",data)
jj_handout(TEMPLATE_BASE + "/src/driver.sh", LAB_DEST + "/src/driver.sh",data) jj_handout(TEMPLATE_BASE + "/src/driver.sh", LAB_DEST + "/src/driver.sh",data)
jj(TEMPLATE_BASE + "/Makefile", LAB_DEST + "/Makefile", data) jj(TEMPLATE_BASE + "/Makefile", LAB_DEST + "/Makefile", data)
shutil.copyfile(TEMPLATE_BASE + "/hello.yml", f"{LAB_DEST}/{base_name}.yml") jj(TEMPLATE_BASE + "/autograde-Makefile", LAB_DEST + "/autograde-Makefile",data=data)
shutil.copyfile(TEMPLATE_BASE + "/autograde-Makefile", LAB_DEST + "/autograde-Makefile")
jj(TEMPLATE_BASE + "/hello.yml", f"{LAB_DEST}/{base_name}.yml", data=data) jj(TEMPLATE_BASE + "/hello.yml", f"{LAB_DEST}/{base_name}.yml", data=data)
jj(TEMPLATE_BASE + "/hello.rb", f"{LAB_DEST}/{base_name}.rb", data=data) jj(TEMPLATE_BASE + "/hello.rb", f"{LAB_DEST}/{base_name}.rb", data=data)
# Copy the student grade file to remove. # Copy the student grade file to remove.
shutil.copyfile(INSTRUCTOR_GRADE_FILE, f"{LAB_DEST}/src/{os.path.basename(INSTRUCTOR_GRADE_FILE)}") shutil.copyfile(INSTRUCTOR_GRADE_FILE, f"{LAB_DEST}/src/{os.path.basename(INSTRUCTOR_GRADE_FILE)}")
shutil.copyfile(STUDENT_TOKEN_FILE, f"{LAB_DEST}/src/{os.path.basename(STUDENT_TOKEN_FILE)}") shutil.copyfile(STUDENT_TOKEN_FILE, f"{LAB_DEST}/src/{handin_filename}")
shutil.copyfile(STUDENT_TOKEN_FILE, f"{LAB_DEST}/src/{tname}") shutil.make_archive(LAB_DEST + '/src/student_sources', 'zip', root_dir=STUDENT_BASE, base_dir='cs101')
# zipFilesInDir(STUDENT_HANDOUT_DIR, LAB_DEST + '/student_sources.zip', lambda name: True)
# Make a zip file of all the students (handed out) sources.
shutil.make_archive(LAB_DEST + '/src/student_sources', 'zip', root_dir=os.path.dirname(STUDENT_HANDOUT_DIR), base_dir='cs101')
# Take the (student) .token file and unpack sources into the student_sources.zip directory.
# docker_helpers
shutil.copyfile(docker_helpers.__file__, f"{LAB_DEST}/src/{os.path.basename(docker_helpers.__file__)}") shutil.copyfile(docker_helpers.__file__, f"{LAB_DEST}/src/{os.path.basename(docker_helpers.__file__)}")
os.mkdir(LAB_DEST +"/handin") os.mkdir(LAB_DEST +"/handin")
os.mkdir(LAB_DEST +"/test-autograder") # Otherwise make clean will screw up. os.mkdir(LAB_DEST +"/test-autograder") # Otherwise make clean will screw up.
os.system(f"cd {LAB_DEST} && make && cd {CURDIR}") os.system(f"cd {LAB_DEST} && make && cd {CURDIR}")
print("Deploy", base_name) print("Deploy", base_name)
if __name__ == "__main__": if __name__ == "__main__":
# print("Hello there handsome")
print("Deploying to", COURSES_BASE) print("Deploying to", COURSES_BASE)
deploy_assignment("hello3") deploy_assignment("hello4")
...@@ -12,8 +12,8 @@ handout: ...@@ -12,8 +12,8 @@ handout:
(rm -rf $(LAB)-handout; mkdir $(LAB)-handout) (rm -rf $(LAB)-handout; mkdir $(LAB)-handout)
cp -p src/Makefile-handout $(LAB)-handout/Makefile cp -p src/Makefile-handout $(LAB)-handout/Makefile
cp -p src/README-handout $(LAB)-handout/README cp -p src/README-handout $(LAB)-handout/README
cp -p src/hello3.c-handout $(LAB)-handout/hello3.c # cp -p src/hello3.c-handout $(LAB)-handout/hello3.c
cp -p src/driver.sh $(LAB)-handout #cp -p src/driver.sh $(LAB)-handout
{%- for f in src_files_to_handout %} {%- for f in src_files_to_handout %}
cp -p src/{{f}} $(LAB)-handout cp -p src/{{f}} $(LAB)-handout
{% endfor %} {% endfor %}
......
all: all:
tar xvf autograde.tar tar xf autograde.tar
cp hello3.c hello3-handout cp {{handin_filename}} {{base_name}}-handout
(cd hello3-handout; sh driver.sh) (cd {{base_name}}-handout; python3 driver_python.py)
clean: clean:
rm -rf *~ hello3-handout rm -rf *~ hello3-handout
require "AssessmentBase.rb" require "AssessmentBase.rb"
module Hello3 module {{base_name|capitalize}}
include AssessmentBase include AssessmentBase
def assessmentInitialize(course) def assessmentInitialize(course)
super("hello3",course) super("{{base_name}}",course)
@problems = [] @problems = []
end end
......
--- ---
general: general:
name: {{ base_name }} name: {{ base_name }}
description: '' description: ''
display_name: Hello3 display_name: {{ display_name }}
handin_filename: hello3.c handin_filename: {{ handin_filename }}
handin_directory: handin handin_directory: handin
max_grace_days: 0 max_grace_days: 0
handout: hello3-handout.tar handout: {{ base_name }}-handout.tar
writeup: writeup/hello3.html writeup: writeup/{{base_name}}.html
max_submissions: -1 max_submissions: -1
disable_handins: false disable_handins: false
max_size: 2 max_size: 2
has_svn: false has_svn: false
category_name: Lab category_name: Lab
problems: problems:
- name: Correctness {% for p in problems %}
description: '' - name: {{ p.name }}
max_score: 100.0 description: '{{p.description}}'
optional: false max_score: {{p.max_score}}
optional: {{p.optional}}
{% endfor %}
autograder: autograder:
autograde_timeout: 180 autograde_timeout: 180
autograde_image: {{ autograde_image }} autograde_image: {{ autograde_image }}
release_score: true release_score: true
# problems:
# - name: Correctness
# description: ''
# max_score: 100.0
# optional: false
\ No newline at end of file
# Makefile for the Hello Lab # Makefile for the Hello Lab
all: all:
gcc hello3.c -o hello3 echo "Makefile called... it is empty so far. "
#gcc hello3.c -o hello3
clean: clean:
rm -rf *~ hello3 rm -rf *~ hello3
......
# Student makefile for the Hello Lab # Student makefile for the Hello Lab
all: all:
echo "handout makefile called.."
gcc hello.c -o hello gcc hello.c -o hello
clean: clean:
......
...@@ -10,25 +10,25 @@ ...@@ -10,25 +10,25 @@
# python3 --version # python3 --version
python3 driver_python.py python3 driver_python.py
(make clean; make) #(make clean; make)
status=$? #status=$?
if [ ${status} -ne 0 ]; then #if [ ${status} -ne 0 ]; then
echo "Failure: Unable to compile hello3.c (return status = ${status})" # echo "Failure: Unable to compile hello3.c (return status = ${status})"
echo "{\"scores\": {\"Correctness\": 0}}" # echo "{\"scores\": {\"Correctness\": 0}}"
exit # exit
fi #fi
#
# Run the code # Run the code
echo "Running ./hello3" #echo "Running ./hello3"
./hello3 #./hello3
status=$? #status=$?
if [ ${status} -eq 0 ]; then #if [ ${status} -eq 0 ]; then
echo "Success: ./hello3 runs with an exit status of 0" # echo "Success: ./hello3 runs with an exit status of 0"
echo "{\"scores\": {\"Correctness\": 100}}" # echo "{\"scores\": {\"Correctness\": 100}}"
else #else
echo "Failure: ./hello fails or returns nonzero exit status of ${status}" # echo "Failure: ./hello fails or returns nonzero exit status of ${status}"
echo "{\"scores\": {\"Correctness\": 0}}" # echo "{\"scores\": {\"Correctness\": 0}}"
fi #fi
exit exit
print("="*10)
tag = "[driver_python.py]"
print(tag, "I am going to have a chamor of a time grading your file!")
import os import os
import glob import glob
import shutil
import sys import sys
import pickle import pickle
# import io # import io
import subprocess
import docker_helpers
import time import time
print("="*10)
tag = "[driver_python.py]"
print(tag, "I am going to have a chamor of a time evaluating your stuff")
sys.stderr = sys.stdout sys.stderr = sys.stdout
wdir = os.getcwd() wdir = os.getcwd()
# print(os.system("cd")) # print(os.system("cd"))
def pfiles(): def pfiles():
print("> Files in dir:") print("> Files in dir:")
for f in glob.glob(wdir + "/*"): for f in glob.glob(wdir + "/*"):
...@@ -21,7 +22,7 @@ def pfiles(): ...@@ -21,7 +22,7 @@ def pfiles():
print("---") print("---")
# shutil.unpack_archive("student_sources.zip") # shutil.unpack_archive("student_sources.zip")
student_token_file = '{{student_token_file}}' student_token_file = '{{handin_filename}}'
instructor_grade_script = '{{instructor_grade_file}}' instructor_grade_script = '{{instructor_grade_file}}'
grade_file_relative_destination = "{{grade_file_relative_destination}}" grade_file_relative_destination = "{{grade_file_relative_destination}}"
with open(student_token_file, 'rb') as f: with open(student_token_file, 'rb') as f:
...@@ -30,55 +31,49 @@ sources = results['sources'][0] ...@@ -30,55 +31,49 @@ sources = results['sources'][0]
pfiles() pfiles()
host_tmp_dir = wdir + "/tmp" host_tmp_dir = wdir + "/tmp"
import subprocess
import docker_helpers
print(f"{host_tmp_dir=}") print(f"{host_tmp_dir=}")
print(f"{student_token_file=}") print(f"{student_token_file=}")
print(f"{instructor_grade_script=}") print(f"{instructor_grade_script=}")
command, token = docker_helpers.student_token_file_runner(host_tmp_dir, student_token_file, instructor_grade_script, grade_file_relative_destination) command, token = docker_helpers.student_token_file_runner(host_tmp_dir, student_token_file, instructor_grade_script, grade_file_relative_destination)
command = f"cd tmp && {command}" command = f"cd tmp && {command} --noprogress --autolab"
def rcom(cm): def rcom(cm):
print(f"running... ", cm) # print(f"running... ", cm)
start = time.time() # start = time.time()
rs = subprocess.run(cm, capture_output=True, text=True, shell=True) rs = subprocess.run(cm, capture_output=True, text=True, shell=True)
print(rs) print(rs.stdout)
print("result of running command was", rs.stdout, "err", rs.stderr, "time", time.time() - start) if len(rs.stderr) > 0:
rcom("ls") print("There were errors in executing the file:")
rcom('python3 --version') print(rs.stderr)
rcom('python --version') # print(rs)
# print("result of running command was", rs.stdout, "err", rs.stderr, "time", time.time() - start)
start = time.time() start = time.time()
rcom(command) rcom(command)
# print("Calling sub process...") # pfiles()
# result = subprocess.run(command.split(), capture_output=True, text=True, shell=True).stdout # for f in glob.glob(host_tmp_dir + "/cs101/*"):
# print("result of running command was", result, "time", time.time() - start) # print("cs101/", f)
# print("---")
import time
time.sleep(1)
# print("> Files in dir:")
pfiles()
for f in glob.glob(host_tmp_dir + "/cs101/*"):
print("cs101/", f)
print("---")
print(f"{token=}") print(f"{token=}")
ls = glob.glob(token) ls = glob.glob(token)
print(ls) # print(ls)
f = ls[0] f = ls[0]
with open(f, 'rb') as f: with open(f, 'rb') as f:
results = pickle.load(f) results = pickle.load(f)
print("results") # print("results")
# print(results.keys())
print(results['total']) print(results['total'])
# if os.path.exists(host_tmp_dir): # if os.path.exists(host_tmp_dir):
# shutil.rmtree(host_tmp_dir) # shutil.rmtree(host_tmp_dir)
# with io.BytesIO(sources['zipfile']) as zb: # with io.BytesIO(sources['zipfile']) as zb:
# with zipfile.ZipFile(zb) as zip: # with zipfile.ZipFile(zb) as zip:
# zip.extractall(host_tmp_dir # zip.extractall(host_tmp_dir
print("="*10) # print("="*10)
\ No newline at end of file # print('{"scores": {"Correctness": 100, "Problem 1": 4}}')
sc = [('Total', results['total'][0])] + [(q['title'], q['obtained']) for k, q in results['details'].items()]
ss = ", ".join([f'"{t}": {s}' for t, s in sc])
scores = '{"scores": {' + ss + '}}'
print('{"_presentation": "semantic"}')
print(scores)
File added
...@@ -16,7 +16,6 @@ class Week1(UTestCase): ...@@ -16,7 +16,6 @@ class Week1(UTestCase):
self.assertEqualC(reverse_list([1,2,3])) self.assertEqualC(reverse_list([1,2,3]))
class Question2(UTestCase): class Question2(UTestCase):
""" Second problem """ """ Second problem """
@cache @cache
......
No preview for this file type
File added
No preview for this file type
File added
from report1 import Report1
from unitgrade_private2.hidden_create_files import setup_grade_file_report
from snipper import snip_dir
import shutil
if __name__ == "__main__":
setup_grade_file_report(Report1, minify=False, obfuscate=False, execute=False)
# Deploy the files using snipper: https://gitlab.compute.dtu.dk/tuhe/snipper
snip_dir.snip_dir(source_dir="../cs101", dest_dir="../../students/cs101", clean_destination_dir=True, exclude=['__pycache__', '*.token', 'deploy.py'])
# For my own sake, copy the homework to the other examples.
for f in ['../../../example_framework/instructor/cs102/homework1.py', '../../../example_docker/instructor/cs103/homework1.py']:
shutil.copy('homework1.py', f)
def reverse_list(mylist): #!f """
Example student code. This file is automatically generated from the files in the instructor-directory
"""
def reverse_list(mylist):
""" """
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g. Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
reverse_list([1,2,3]) should return [3,2,1] (as a list). reverse_list([1,2,3]) should return [3,2,1] (as a list).
""" """
return list(reversed(mylist)) # TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
def add(a,b): #!f def add(a,b):
""" Given two numbers `a` and `b` this function should simply return their sum: """ Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """ > add(a,b) = a+b """
return a+b # TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
if __name__ == "__main__": if __name__ == "__main__":
# Problem 1: Write a function which add two numbers # Problem 1: Write a function which add two numbers
......
"""
Example student code. This file is automatically generated from the files in the instructor-directory
"""
from unitgrade2.unitgrade2 import Report from unitgrade2.unitgrade2 import Report
from unitgrade2.unitgrade_helpers2 import evaluate_report_student from unitgrade2.unitgrade_helpers2 import evaluate_report_student
from cs101.homework1 import reverse_list, add from cs101.homework1 import reverse_list, add
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment