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

updates

parent d3b39e1e
No related branches found
No related tags found
No related merge requests found
Showing
with 90 additions and 23 deletions
File added
File added
File added
......@@ -31,8 +31,8 @@ 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 = deploy_student_files()
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]
......
No preview for this file type
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'])
"""
Example student code. This file is automatically generated from the files in the instructor-directory
"""
def reverse_list(mylist):
def reverse_list(mylist): #!f
"""
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).
"""
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
return list(reversed(mylist))
def add(a,b):
def add(a,b): #!f
""" Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
return a+b
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
......
from unitgrade2.unitgrade2 import UTestCase, Report, hide
from unitgrade2.unitgrade_helpers2 import evaluate_report_student
class Week1(UTestCase):
""" The first question for week 1. """
def test_add(self):
from cs103.homework1 import add
self.assertEqualC(add(2,2))
self.assertEqualC(add(-100, 5))
@hide
def test_add_hidden(self):
# This is a hidden test. The @hide-decorator will allow unitgrade to remove the test.
# See the output in the student directory for more information.
from cs103.homework1 import add
self.assertEqualC(add(2,2))
import cs103
class Report3(Report):
title = "CS 101 Report 3"
questions = [(Week1, 20)] # Include a single question for 10 credits.
pack_imports = [cs103]
if __name__ == "__main__":
evaluate_report_student(Report3())
No preview for this file type
File added
File added
File added
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment