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

updates

parent bafbf14b
No related branches found
No related tags found
No related merge requests found
Showing
with 653 additions and 399 deletions
This diff is collapsed.
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -12,7 +12,7 @@ from snipper.snip_dir import snip_dir
def deploy_student_files():
setup_grade_file_report(Report3, minify=False, obfuscate=False, execute=False)
Report3.reset()
# Report3.reset()
fout, ReportWithoutHidden = remove_hidden_methods(Report3, outfile="report3.py")
setup_grade_file_report(ReportWithoutHidden, minify=False, obfuscate=False, execute=False)
......@@ -31,8 +31,10 @@ def run_student_code_on_docker(Dockerfile, student_token_file):
if __name__ == "__main__":
# Step 1: Deploy the students files and return the directory they were written to
# student_directory = deploy_student_files()
student_directory = "../../students/cs103"
student_directory = deploy_student_files()
# import sys
# sys.exit()
# student_directory = "../../students/cs103"
# Step 2: Simulate that the student run their report script and generate a .token file.
os.system("cd ../../students && python -m cs103.report3_grade")
student_token_file = glob.glob(student_directory + "/*.token")[0]
......
......@@ -9,10 +9,15 @@ class Week1(UTestCase):
self.assertEqualC(add(-100, 5))
class AutomaticPass(UTestCase):
def test_student_passed(self):
self.assertEqual(2,2)
import cs103
class Report3(Report):
title = "CS 101 Report 3"
questions = [(Week1, 20)] # Include a single question for 10 credits.
questions = [(Week1, 20), (AutomaticPass, 10)] # Include a single question for 10 credits.
pack_imports = [cs103]
if __name__ == "__main__":
......
......@@ -15,10 +15,18 @@ class Week1(UTestCase):
from cs103.homework1 import add
self.assertEqualC(add(2,2))
class AutomaticPass(UTestCase):
def test_student_passed(self):
self.assertEqual(2,2)
@hide
def test_hidden_fail(self):
self.assertEqual(2,3)
import cs103
class Report3(Report):
title = "CS 101 Report 3"
questions = [(Week1, 20)] # Include a single question for 10 credits.
questions = [(Week1, 20), (AutomaticPass, 10)] # Include a single question for 10 credits.
pack_imports = [cs103]
if __name__ == "__main__":
......
This diff is collapsed.
File added
No preview for this file type
File added
import inspect
from cs103.report3_complete import Report3
from unitgrade_private2.hidden_create_files import setup_grade_file_report
from unitgrade_private2.hidden_gather_upload import gather_upload_to_campusnet
from unitgrade_private2.deployment import remove_hidden_methods
from unitgrade_private2.docker_helpers import docker_run_token_file
import shutil
import os
import glob
import pickle
from snipper.snip_dir import snip_dir
def deploy_student_files():
setup_grade_file_report(Report3, minify=False, obfuscate=False, execute=False)
Report3.reset()
fout, ReportWithoutHidden = remove_hidden_methods(Report3, outfile="report3.py")
setup_grade_file_report(ReportWithoutHidden, minify=False, obfuscate=False, execute=False)
sdir = "../../students/cs103"
snip_dir(source_dir="../cs103", dest_dir=sdir, clean_destination_dir=True, exclude=['__pycache__', '*.token', 'deploy.py', 'report3_complete*.py'])
return sdir
def run_student_code_on_docker(Dockerfile, student_token_file):
token = docker_run_token_file(Dockerfile_location=Dockerfile,
host_tmp_dir=os.path.dirname(Dockerfile) + "/tmp",
student_token_file=student_token_file,
instructor_grade_script="report3_complete_grade.py")
with open(token, 'rb') as f:
results = pickle.load(f)
return results
if __name__ == "__main__":
# Step 1: Deploy the students files and return the directory they were written to
student_directory = deploy_student_files()
# Step 2: Simulate that the student run their report script and generate a .token file.
os.system("cd ../../students && python -m cs103.report3_grade")
student_token_file = glob.glob(student_directory + "/*.token")[0]
# Step 3: Compile the Docker image (obviously you will only do this once; add your packages to requirements.txt).
Dockerfile = os.path.dirname(__file__) + "/../unitgrade-docker/Dockerfile"
os.system("cd ../unitgrade-docker && docker build --tag unitgrade-docker .")
# Step 4: Test the students .token file and get the results-token-file. Compare the contents with the students_token_file:
checked_token = run_student_code_on_docker(Dockerfile, student_token_file)
# Let's quickly compare the students score to what we got (the dictionary contains all relevant information including code).
with open(student_token_file, 'rb') as f:
results = pickle.load(f)
print("Student's score was:", results['total'])
print("My independent evaluation of the students score was", checked_token['total'])
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.
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:
> add(a,b) = a+b """
return a+b
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
if __name__ == "__main__":
# 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 UTestCase, Report, hide
from unitgrade2.unitgrade_helpers2 import evaluate_report_student
......@@ -9,10 +12,15 @@ class Week1(UTestCase):
self.assertEqualC(add(-100, 5))
class AutomaticPass(UTestCase):
def test_student_passed(self):
self.assertEqual(2,2)
import cs103
class Report3(Report):
title = "CS 101 Report 3"
questions = [(Week1, 20)] # Include a single question for 10 credits.
questions = [(Week1, 20), (AutomaticPass, 10)] # Include a single question for 10 credits.
pack_imports = [cs103]
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment