Skip to content
Snippets Groups Projects
Commit cffea77a authored by Tue Herlau's avatar Tue Herlau
Browse files

Options

parent 1968cc6b
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,9 @@
<component name="ChangeListManager">
<list default="true" id="5c346737-53d8-4e87-88c5-7be2c8e7baeb" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unitgrade/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/unitgrade/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unitgrade/unitgrade.py" beforeDir="false" afterPath="$PROJECT_DIR$/unitgrade/unitgrade.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unitgrade/unitgrade_helpers.py" beforeDir="false" afterPath="$PROJECT_DIR$/unitgrade/unitgrade_helpers.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -135,7 +138,7 @@
<recent name="C:\Users\tuhe\Documents\unitgrade_private" />
</key>
</component>
<component name="RunManager" selected="Python.cs101report1">
<component name="RunManager" selected="Python.cs101report2">
<configuration name="cs101report1" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="unitgrade" />
<option name="INTERPRETER_OPTIONS" value="" />
......@@ -178,7 +181,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="deploy_cs101 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="cs101report2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="unitgrade" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -190,7 +193,28 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../unitgrade_private/cs101courseware/deploy_cs101.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../unitgrade_private/cs101courseware/cs101report2.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="cs101report2_grade" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="unitgrade" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../unitgrade_private/cs101courseware" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../unitgrade_private/cs101courseware/cs101report2_grade.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -199,7 +223,7 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="deploy_cs101" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="deploy_cs101 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="unitgrade" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -211,7 +235,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="C:\Users\tuhe\Documents\unitgrade_private\cs101courseware\deploy_cs101.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../unitgrade_private/cs101courseware/deploy_cs101.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -243,17 +267,19 @@
</configuration>
<list>
<item itemvalue="Python.cs101report1" />
<item itemvalue="Python.deploy_cs101" />
<item itemvalue="Python.deploy_cs101 (1)" />
<item itemvalue="Python.instructions" />
<item itemvalue="Python.cs101report1_grade" />
<item itemvalue="Python.cs101report2" />
<item itemvalue="Python.cs101report2_grade" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.cs101report2" />
<item itemvalue="Python.cs101report2_grade" />
<item itemvalue="Python.instructions" />
<item itemvalue="Python.cs101report1_grade" />
<item itemvalue="Python.deploy_cs101 (1)" />
<item itemvalue="Python.deploy_cs101" />
</list>
</recent_temporary>
</component>
......@@ -313,21 +339,13 @@
</map>
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/../unitgrade_private/unitgrade_private/hidden_create_files.py</url>
<line>102</line>
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/unitgrade/unitgrade_helpers.py</url>
<line>54</line>
<option name="timeStamp" value="19" />
<url>file://$PROJECT_DIR$/../unitgrade_private/cs101courseware/cs101report2.py</url>
<line>43</line>
<option name="timeStamp" value="44" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
......
......@@ -2,6 +2,7 @@ __version__ = "0.0.4"
import os
import compress_pickle
def cache_write(object, file_name, verbose=True):
dn = os.path.dirname(file_name)
if not os.path.exists(dn):
......@@ -26,3 +27,4 @@ def cache_read(file_name):
else:
return None
from unitgrade.unitgrade import Hidden, myround
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -20,6 +20,10 @@ def setup_dir_by_class(C,base_dir):
# os.makedirs(base_dir)
return base_dir, name
class Hidden:
def hide(self):
return True
class Capturing(list):
def __enter__(self, capture_errors=True):
self._stdout = sys.stdout
......
......@@ -3,11 +3,17 @@ from tabulate import tabulate
from datetime import datetime
import pickle
import pyfiglet
# from unitgrade.unitgrade import Hidden
# import unitgrade as ug
import unitgrade
# import unitgrade.unitgrade as ug
from unitgrade import Hidden, myround
import inspect
import os
import argparse
parser = argparse.ArgumentParser(description='Evaluate your report.', epilog="""Example:
To run all tests in a report:
......@@ -66,6 +72,17 @@ def evaluate_report_student(report, question=None, qitem=None):
print("In the same manner as you ran this file.")
return results
def upack(q):
# h = zip([(i['w'], i['possible'], i['obtained']) for i in q.values()])
h =[(i['w'], i['possible'], i['obtained']) for i in q.values()]
h = np.asarray(h)
return h[:,0], h[:,1], h[:,2],
#
# ws, possible, obtained = (np.asarray(x).squeeze() for x in zip([(i['w'], i['possible'], i['obtained']) for i in q.values()]))
# return ws, possible, obtained
def evaluate_report(report, question=None, qitem=None):
now = datetime.now()
ascii_banner = pyfiglet.figlet_format("UnitGrade", font="doom")
......@@ -76,11 +93,14 @@ def evaluate_report(report, question=None, qitem=None):
print("Evaluating " + report.title, "(use --help for options)")
print("")
report.obtained = 0
report.possible = 0
# report.obtained = 0
# report.possible = 0
table_data = []
nL = 80
score = {}
for n, (q, w) in enumerate(report.questions):
q_hidden = issubclass(q.__class__, Hidden)
if question is not None and n+1 != question:
continue
......@@ -88,6 +108,8 @@ def evaluate_report(report, question=None, qitem=None):
print("="*nL)
q.possible = 0
q.obtained = 0
q_ = {} # Gather score in this class.
for j, (item, iw) in enumerate(q.items):
if qitem is not None and question is not None and item is not None and j+1 != qitem:
continue
......@@ -96,18 +118,28 @@ def evaluate_report(report, question=None, qitem=None):
el = nL-4
if len(ss) < el:
ss += '.'*(el-len(ss))
hidden = issubclass(item.__class__, Hidden)
if not hidden:
print(ss, end="")
(current, possible) = item.get_points()
q.possible += possible * iw
q.obtained += current * iw
q_[j] = {'w': iw, 'possible': possible, 'obtained': current, 'hidden': hidden}
# q.possible += possible * iw
# q.obtained += current * iw
if not hidden:
if current == possible:
print(f"PASS")
else:
print(f"*** FAILED")
from unitgrade.unitgrade import myround
q.obtained = myround(np.floor((w * q.obtained) / q.possible)) if q.possible > 0 else 0
report.obtained += q.obtained
report.possible += w
# score[q] = {'w': w, }
# from unitgrade.unitgrade import myround
ws, obtained, possible = upack(q_)
possible = int(ws @ possible)
obtained = int(ws @ obtained)
obtained = myround(np.floor((w * obtained) / possible )) if possible > 0 else 0
score[n] = {'w': w, 'possible': w, 'obtained': obtained, 'ítems': q_, 'hidden': q_hidden}
q.obtained = obtained
q.possible = possible
s1 = f"*** Question q{n+1}"
s2 = f" {q.obtained}/{w}"
......@@ -115,9 +147,14 @@ def evaluate_report(report, question=None, qitem=None):
print(" ")
table_data.append([f"Question q{n+1}", f"{q.obtained}/{w}"])
ws, obtained, possible = upack(score)
possible = int( sum(possible) )
obtained = int( sum(obtained) ) # Cast to python int
report.possible = possible
report.obtained = obtained
now = datetime.now()
dt_string = now.strftime("%H:%M:%S")
print(f"Completed: "+ dt_string)
table_data.append(["Total", ""+str(report.obtained)+"/"+str(report.possible) ])
results = {'total': (report.obtained, report.possible)}
results = {'total': (obtained, possible), 'details': score}
return results, table_data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment