summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ExampleAssessments/CMP-4009B.yml24
-rw-r--r--mark.py52
-rw-r--r--reflect.py31
-rw-r--r--reportWriter.py0
-rw-r--r--requirements.txt1
5 files changed, 108 insertions, 0 deletions
diff --git a/ExampleAssessments/CMP-4009B.yml b/ExampleAssessments/CMP-4009B.yml
new file mode 100644
index 0000000..373f7f4
--- /dev/null
+++ b/ExampleAssessments/CMP-4009B.yml
@@ -0,0 +1,24 @@
+files:
+ - pjtool.py:
+ classes:
+ - Date:
+ methods:
+ - __init__(4)
+ - __str__(1)
+ - __eq__(2)
+ - __lt__(2)
+ - numYears(2)
+ - numMonths(2)
+ tests:
+ - |
+ d1 = Date(2001, 8, 12)
+ d2 = Date(2001, 8, 12)
+ return d1 == d2
+ - tester.py:
+ functions:
+ - dateTester(2)
+ - turbine.py:
+ classes:
+ - Turbine:
+ attributes:
+ - rating:int \ No newline at end of file
diff --git a/mark.py b/mark.py
new file mode 100644
index 0000000..f1ffa59
--- /dev/null
+++ b/mark.py
@@ -0,0 +1,52 @@
+import argparse
+import tempfile
+import zipfile
+import yaml
+import os
+
+def main(assessment_path, submission_path, student_no):
+ print(student_no)
+
+ with open(assessment_path, "r") as f:
+ assessment_struct = yaml.safe_load(f)
+
+ print(assessment_struct)
+
+ for required_file in assessment_struct["files"]:
+ required_file = list(required_file.keys())[0]
+ print(required_file, required_file in os.listdir(submission_path))
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "-a", "--assessment",
+ help = "Path to an assessment .yml file",
+ type = str,
+ required = True
+ )
+ parser.add_argument(
+ "-s", "--submission",
+ help = "Path to a zip of a student's code",
+ type = str,
+ required = True
+ )
+ args = vars(parser.parse_args())
+
+ with tempfile.TemporaryDirectory() as tempdir:
+ with zipfile.ZipFile(args["submission"]) as z:
+ z.extractall(tempdir)
+
+ # some zipping applications make a folder inside the zip with the files in that folder.
+ # try to deal with this here.
+ submission_files = tempdir
+ if os.path.isdir(
+ os.path.join(submission_files, os.listdir(submission_files)[0])
+ ) and len(os.listdir(submission_files)) == 1:
+ submission_files = os.path.join(submission_files, os.listdir(submission_files)[0])
+
+ main(
+ args["assessment"],
+ submission_files,
+ os.path.splitext(os.path.split(args["submission"])[-1])[0]
+ )
+ \ No newline at end of file
diff --git a/reflect.py b/reflect.py
new file mode 100644
index 0000000..2cfb2f3
--- /dev/null
+++ b/reflect.py
@@ -0,0 +1,31 @@
+from dataclasses import dataclass
+import importlib
+import inspect
+import pkgutil
+import sys
+import os
+
+@dataclass
+class Reflect:
+ client_code_path:str
+ imported_modules = {}
+
+ def __post_init__(self):
+ sys.path.insert(1, self.client_code_path)
+ self.client_modules = [p for p in pkgutil.iter_modules() if str(p[0])[12:-2] == self.client_code_path]
+
+ def import_module(self, module_name):
+ for module in self.client_modules:
+ if module.name == module_name:
+ self.imported_modules[module_name] = importlib.import_module(module.name)
+
+ def get_module_doc(self, module_name):
+ return inspect.getdoc(self.imported_modules[module_name])
+
+
+if __name__ == "__main__":
+ user_code_path = "/media/veracrypt1/Nextcloud/UniStuff/3.0 - CMP 3rd Year Project/ExampleSubmissions/Submission_A"
+
+ reflect = Reflect(user_code_path)
+ reflect.import_module("pjtool")
+ print(reflect.get_module_doc("pjtool"))
diff --git a/reportWriter.py b/reportWriter.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/reportWriter.py
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..bee6c14
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+PyYAML==6.0