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

Working on the dashboard

parent ba4e096c
No related branches found
No related tags found
No related merge requests found
Showing
with 674 additions and 63 deletions
File added
from cs108.report_devel import Report2
from cs108.report_devel import Report2, mk_ok
from unitgrade_private.hidden_create_files import setup_grade_file_report
from snipper.snip_dir import snip_dir
def main(with_coverage=True):
mk_ok()
setup_grade_file_report(Report2, with_coverage=with_coverage, minify=False, obfuscate=False,bzip=False)
if __name__ == "__main__":
# import pickle
# with open("unitgrade_data/Week1.pkl", 'rb') as f:
......@@ -15,5 +20,6 @@ if __name__ == "__main__":
# data, txt = load_token("Report2_handin_38_of_38.token")
# print(data['details'][1]['items'] )
setup_grade_file_report(Report2, with_coverage=True)
snip_dir("./", "../../students/cs108", clean_destination_dir=True, exclude=['*.token', 'deploy.py'])
# None of that coverage shit.
# snip_dir("./", "../../students/cs108", clean_destination_dir=True, exclude=['*.token', 'deploy.py'])
main()
......@@ -4,20 +4,71 @@ from cs108.homework1 import add, reverse_list, linear_regression_weights, linear
from unitgrade import UTestCase, cache
import time
import numpy as np
import pickle
import os
def mk_bad():
with open(os.path.dirname(__file__)+"/db.pkl", 'wb') as f:
d = {'x1': 100, 'x2': 300}
pickle.dump(d, f)
def mk_ok():
with open(os.path.dirname(__file__)+"/db.pkl", 'wb') as f:
d = {'x1': 1, 'x2': 2}
pickle.dump(d, f)
class Numpy(UTestCase):
@classmethod
def setUpClass(cls) -> None:
print("Set up.") # must be handled seperately.
# raise Exception("bad set up class")
def test_bad(self):
"""
Hints:
* Remember to properly de-indent your code.
* Do more stuff which works.
"""
# raise Exception("This ended poorly")
# print("Here we go")
# return
# self.assertEqual(1, 1)
with open(os.path.dirname(__file__)+"/db.pkl", 'rb') as f:
# d = {'x1': 1, 'x2': 2}
# pickle.dump(d, f)
d = pickle.load(f)
# print(d)
# assert False
for i in range(10):
print("The current number is", i)
# time.sleep(1)
self.assertEqual(1, d['x1'])
# assert False
pass
def test_weights(self):
"""
Hints:
* Try harder!
* Check the chapter on linear regression.
"""
n = 3
m = 2
np.random.seed(5)
X = np.random.randn(n, m)
y = np.random.randn(n)
# from numpy import asdfaskdfj
# X = np.random.randn(n, m)
# y = np.random.randn(n)
foo()
self.assertL2(linear_regression_weights(X, y), msg="the message")
# assert 2 == 3
# raise Exception("Bad exit")
# self.assertEqual(2, np.random.randint(1000))
# self.assertEqual(2, np.random.randint(1000))
# self.assertL2(linear_regression_weights(X, y), msg="the message")
self.assertEqual(1, 1)
# self.assertEqual(1,2)
return "THE RESULT OF THE TEST"
......@@ -30,4 +81,8 @@ class Report2(Report):
pack_imports = [cs108]
if __name__ == "__main__":
evaluate_report_student(Report2())
# import texttestrunner
import unittest
unittest.main(exit=False)
# evaluate_report_student(Report2())
{"run_id": 345491, "state": "running", "coverage_files_changed": null}
\ No newline at end of file
No preview for this file type
{"encoding_scheme": " from unitgrade_private.hidden_gather_upload import dict2picklestring, picklestring2dict;", "questions": "/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4AHyAVFdAEABDnx/coDphHtjJz/Hf6BMJ8jsKcX6D2GlIpCTdQefBtKe4zVRUqE7IM4RD5R3T2C+GesRy0Q5CgrFjodW6xsauaOPVgMwAO1n3axAyU1UhpvS1V4sPs0g7xaNtsCv8oRoe1AhKnl3IFDf6Gg6nXO36ces1MgE7xDz9CSsQ5T2chCmCFLNziwvyXiZKmi6MvcRQ49bpAWpgL4hLMkYc3stfxkRNFCND+MKghupeHwxC4fWNFnP648dKpkQg5xXbkFyD+544w0PH+PJ5pebdXG1+e6LAMSZhOnTHNgUV/SOoiYRLohCowLRTz82ihjKzZH+EqvquWg5r0Yx3Ja1gRz3xz+q4ucPm5sFnELtxqjQdRQYpfjlaDlfNe0GiwzrpgOXv1Vdggdv/bafsf2KXpOkHIRXexotRNAJX9b9f1h2y/P3pOsllmmzbQXfJYsgvXoAAAAAHE5f2fQPWZMAAe0C8wMAAPGI2oWxxGf7AgAAAAAEWVo=", "root_dir": "/home/tuhe/Documents/unitgrade_private/devel/example_devel/instructor", "relative_path": "cs108/report_devel.py", "modules": ["cs108", "report_devel"]}
\ No newline at end of file
No preview for this file type
......@@ -3,64 +3,73 @@ from unitgrade.evaluate import evaluate_report_student
from cs102.homework1 import add, reverse_list
from unitgrade import UTestCase, cache # !s
class Week1(UTestCase):
def test_add(self):
self.assertEqualC(add(2,2))
self.assertEqualC(add(-100, 5))
def test_reverse(self):
self.assertEqualC(reverse_list([1, 2, 3])) #!s
def test_output_capture(self):
with self.capture() as out:
print("hello world 42") # Genereate some output (i.e. in a homework script)
self.assertEqual(out.numbers[0], 42) # out.numbers is a list of all numbers generated
self.assertEqual(out.output, "hello world 42") # you can also access the raw output.
class Week1(UTestCase):
@classmethod
def setUpClass(cls) -> None:
a = 234
class Week1Titles(UTestCase): #!s=b
""" The same problem as before with nicer titles """
def test_add(self):
""" Test the addition method add(a,b) """
self.assertEqualC(add(2,2))
print("output generated by test")
self.assertEqualC(add(-100, 5))
# self.assertEqual(2,3, msg="This test automatically fails.")
def test_reverse(self):
ls = [1, 2, 3]
reverse = reverse_list(ls)
self.assertEqualC(reverse)
# Although the title is set after the test potentially fails, it will *always* show correctly for the student.
self.title = f"Checking if reverse_list({ls}) = {reverse}" # Programmatically set the title #!s
def ex_test_output_capture(self):
with self.capture() as out:
print("hello world 42") # Genereate some output (i.e. in a homework script)
self.assertEqual(out.numbers[0], 42) # out.numbers is a list of all numbers generated
self.assertEqual(out.output, "hello world 42") # you can also access the raw output.
class Question2(UTestCase): #!s=c
@cache
def my_reversal(self, ls):
# The '@cache' decorator ensures the function is not run on the *students* computer
# Instead the code is run on the teachers computer and the result is passed on with the
# other pre-computed results -- i.e. this function will run regardless of how the student happens to have
# implemented reverse_list.
return reverse_list(ls)
# def test_reverse(self):
# self.assertEqualC(reverse_list([1, 2, 3])) #!s
#
# def test_output_capture(self):
# with self.capture() as out:
# print("hello world 42") # Genereate some output (i.e. in a homework script)
# self.assertEqual(out.numbers[0], 42) # out.numbers is a list of all numbers generated
# self.assertEqual(out.output, "hello world 42") # you can also access the raw output.
def test_reverse_tricky(self):
ls = (2,4,8)
ls2 = self.my_reversal(tuple(ls)) # This will always produce the right result, [8, 4, 2]
print("The correct answer is supposed to be", ls2) # Show students the correct answer
self.assertEqualC(reverse_list(ls)) # This will actually test the students code.
return "Buy world!" # This value will be stored in the .token file #!s=c
# class Week1Titles(UTestCase): #!s=b
# """ The same problem as before with nicer titles """
# def test_add(self):
# """ Test the addition method add(a,b) """
# self.assertEqualC(add(2,2))
# print("output generated by test")
# self.assertEqualC(add(-100, 5))
# # self.assertEqual(2,3, msg="This test automatically fails.")
#
# def test_reverse(self):
# ls = [1, 2, 3]
# reverse = reverse_list(ls)
# self.assertEqualC(reverse)
# # Although the title is set after the test potentially fails, it will *always* show correctly for the student.
# self.title = f"Checking if reverse_list({ls}) = {reverse}" # Programmatically set the title #!s
#
# def ex_test_output_capture(self):
# with self.capture() as out:
# print("hello world 42") # Genereate some output (i.e. in a homework script)
# self.assertEqual(out.numbers[0], 42) # out.numbers is a list of all numbers generated
# self.assertEqual(out.output, "hello world 42") # you can also access the raw output.
#
#
# class Question2(UTestCase): #!s=c
# @cache
# def my_reversal(self, ls):
# # The '@cache' decorator ensures the function is not run on the *students* computer
# # Instead the code is run on the teachers computer and the result is passed on with the
# # other pre-computed results -- i.e. this function will run regardless of how the student happens to have
# # implemented reverse_list.
# return reverse_list(ls)
#
# def test_reverse_tricky(self):
# ls = (2,4,8)
# ls2 = self.my_reversal(tuple(ls)) # This will always produce the right result, [8, 4, 2]
# print("The correct answer is supposed to be", ls2) # Show students the correct answer
# self.assertEqualC(reverse_list(ls)) # This will actually test the students code.
# return "Buy world!" # This value will be stored in the .token file #!s=c
# w = Week1
import cs102
class Report2(Report):
title = "CS 102 Report 2"
questions = [(Week1, 10), (Week1Titles, 6)]
questions = [(Week1, 10),
# (Week1Titles, 6)
]
pack_imports = [cs102]
if __name__ == "__main__":
......
No preview for this file type
No preview for this file type
# report2_test.py
# report2.py
from unitgrade import UTestCase, cache
class Week1(UTestCase):
@classmethod
def setUpClass(cls) -> None:
a = 234
def test_add(self):
self.assertEqualC(add(2,2))
self.assertEqualC(add(-100, 5))
......
# report2_test.py
# report2.py
class Week1Titles(UTestCase):
""" The same problem as before with nicer titles """
def test_add(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment