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

Options

parent 515ec84b
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
<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" />
......@@ -136,8 +138,8 @@
<recent name="C:\Users\tuhe\Documents\unitgrade_private" />
</key>
</component>
<component name="RunManager" selected="Python.cs101report1 (1)">
<configuration name="cs101report1 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<component name="RunManager" selected="Python.cs101report1">
<configuration name="cs101report1" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="unitgrade" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
......@@ -150,7 +152,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/cs101courseware_example/cs101report1.py" />
<option name="PARAMETERS" value="" />
<option name="PARAMETERS" value="-q 2.1" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
......@@ -243,15 +245,14 @@
<method v="2" />
</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 (1)" />
<item itemvalue="Python.cs101report1_grade" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.cs101report1 (1)" />
<item itemvalue="Python.instructions" />
<item itemvalue="Python.cs101report1_grade" />
<item itemvalue="Python.deploy_cs101 (1)" />
......@@ -327,9 +328,9 @@
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/unitgrade/__init__.py</url>
<line>1</line>
<option name="timeStamp" value="17" />
<url>file://$PROJECT_DIR$/unitgrade/unitgrade_helpers.py</url>
<line>54</line>
<option name="timeStamp" value="19" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
......
__version__ = "0.0.2"
__version__ = "0.0.4"
import os
import compress_pickle
......
......@@ -152,12 +152,10 @@ class Report():
def __init__(self):
working_directory = os.path.abspath(os.path.dirname(inspect.getfile(type(self))))
print(working_directory)
# working_directory = os.path.join(pathlib.Path(__file__).parent.absolute(), "payloads/")
self.wdir, self.name = setup_dir_by_class(self, working_directory)
# trace = inspect.trace()
self.computed_answers_file = os.path.join(self.wdir, self.name + "_resources_do_not_hand_in.dat")
print(self.computed_answers_file)
# print(self.computed_answers_file)
self.questions = [(Q(working_directory=self.wdir),w) for Q,w in self.questions]
if os.path.isfile(self.computed_answers_file):
self.set_payload(cache_read(self.computed_answers_file))
......
......@@ -8,16 +8,34 @@ import inspect
import os
import argparse
parser = argparse.ArgumentParser(description='Evaluate your report.')
parser.add_argument('question', nargs='?', type=int, default=None, help='Only evaluate this question')
parser = argparse.ArgumentParser(description='Evaluate your report.', epilog="""Example:
To run all tests in a report:
> python report1.py
To run only question 2 or question 2.1
> python report1.py -q 2
> python report1.py -q 2.1
Note this scripts does not grade your report. To grade your report, use:
> python report1_grade.py
Finally, note that if your report is part of a module (package), and the report script requires part of that package, the -m option for python may be useful.
As an example, suppose the report file is Documents/course_package/report1.py, and `course_package` is a python package. Change directory to 'Documents/` and execute:
> python -m course_package.report1
see https://docs.python.org/3.9/using/cmdline.html
""")
parser.add_argument('-q', nargs='?', type=str, default=None, help='Only evaluate this question (example: -q 2)')
# parser.add_argument('integers', metavar='N', type=int, nargs='+',
# help='an integer for the accumulator')
# parser.add_argument('--sum', dest='accumulate', action='store_const',
# const=sum, default=max,
# help='sum the integers (default: find the max)')
def source_instantiate(name, report1_source, payload):
eval("exec")(report1_source, globals())
report = eval(name)()
......@@ -28,7 +46,12 @@ def source_instantiate(name, report1_source, payload):
def evaluate_report_student(report, question=None, qitem=None):
if question is None:
args = parser.parse_args()
question = args.question
question = args.q
if "." in question:
question, qitem = [int(v) for v in question.split(".")]
else:
question = int(question)
results, table_data = evaluate_report(report, question=question, qitem=qitem)
if question is None:
print("Provisional evaluation")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment