diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..757fee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..81a32ed --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# Submission Document Builder + +**Author:** Dr Ian Cornelius, [ab6459@coventry.ac.uk](mailto:ab6459@coventry.ac.uk) +**Modules**: +- 4017CMD: Introduction to Programming +- 5039CMD: Programming and Operating Systems + +## Requirements + +To build the document for submission, you are required to install the following third-party tools: + +- [Python 3.11+](https://www.python.org/downloads/) +- [Pandoc 3.1.13+](https://pandoc.org/installing.html) +- [TeXLive](https://www.tug.org/texlive/) + +### Python Requirements + +The Python script requires installing the following third-party modules: + +- pandoc-include + +The module can be installed by either one of the following commands: + +```shell +python3 -m pip install pandoc-include +``` +or: +```shell +python3 -m pip install -r requirements.txt +``` + +## Using the Script +If you have not done so already, you will want to clone this repository to your local machine. This can be achieved by +using the following command: + +```shell +git clone https://github.coventry.ac.uk/ab6459/Submission_Document_Builder +``` + +With the script successfully cloned to your machine, you need to place the source code files you want in the submission +document inside the directory called `src`. **It is important that you only include the files in this directory that you +want marking.** + +With the documents placed in the `src` folder, you then need to edit the `config.py` file. This file contains two global +variables: `GIT_REPO_LINK` and `STUDENT_ID`. You must change the value of these variables to: + +- `GIT_REPO_LINK`: the Git repository link you want marking +- `STUDENT_ID`: your student identification number + - this can be found on your student card + +**You must ensure that the Git repository link is correct, and is located inside the organisation for the module you are +submitting for**. For example, if you are submitting coursework for **4017CMD**, you must use the organisation with +**4017CMD** in its title, i.e. `http://github.coventry.ac.uk/4017CMD-23-24/STUDENTID_IPA_A1`. + +Once you have edited the `config.py` file, you can execute the Python script using the following command: + +```shell +python3 create_submission_document.py +``` + +This will create the PDF submission document required for TurnItIn. The generated file will be located in the directory +called `out`. + +## Issues? +If you are struggling to use this script, or having any issues, you can contact Dr Ian Cornelius via e-mail. His e-mail +address is [ab6459@coventry.ac.uk](ab6459@coventry.ac.uk). \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..1798052 --- /dev/null +++ b/config.py @@ -0,0 +1,3 @@ +class Configuration: + GIT_REPO_LINK = "http://github.coventry.ac.uk/4017CMD-23-24/STUDENTID_IPA_A1" + STUDENT_ID = 123456789 \ No newline at end of file diff --git a/create_submission_document.py b/create_submission_document.py new file mode 100644 index 0000000..51c3c80 --- /dev/null +++ b/create_submission_document.py @@ -0,0 +1,32 @@ +from config import Configuration +import os +import subprocess + +if __name__ == '__main__': + + # Grab the Python source-code files to include in the submission document + files = [f for f in os.listdir('src') if os.path.isfile(os.path.join('src/', f))] + + # Create the Markdown version of the submission document + with open(f'{Configuration.STUDENT_ID}_submission_document.md', 'w') as f: + yml = open('header.yml', 'r') + f.write(f'{yml.read()}') + f.write('\n') + yml.close() + f.write('# GitHub Repository Link\n') + f.write(f'{Configuration.GIT_REPO_LINK}\n') + for file in files: + f.write(f'\n\\newpage\n') + f.write(f'# {file}\n') + f.write(f'```python\n') + f.write(f'!include src/{file}\n') + f.write(f'```\n') + + # Create the PDF for submission + mdDoc = os.path.join(f'{Configuration.STUDENT_ID}_submission_document.md') + pdfDoc = os.path.join(f'{Configuration.STUDENT_ID}_submission_document.pdf') + cmd = f'pandoc -s {mdDoc} --listings --filter pandoc-include -o out/{pdfDoc}'.split() + p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate() + + # Delete the Markdown File + os.remove(mdDoc) \ No newline at end of file diff --git a/header.yml b/header.yml new file mode 100644 index 0000000..ed0dcf5 --- /dev/null +++ b/header.yml @@ -0,0 +1,28 @@ +--- +geometry: + - margin=2cm +header-includes: + - \usepackage{listings} + - \usepackage{xcolor} + - \usepackage{titlesec} + - \newcommand{\sectionbreak}{\clearpage} + - \lstset{ + basicstyle=\ttfamily, + keywordstyle=\color[rgb]{0.13,0.29,0.53}\bfseries, + stringstyle=\color[rgb]{0.31,0.60,0.02}, + commentstyle=\color[rgb]{0.56,0.35,0.01}\itshape, + numberstyle=\footnotesize, + showspaces=false, + showstringspaces=false, + showtabs=false, + tabsize=2, + captionpos=b, + breaklines=true, + breakatwhitespace=true, + breakautoindent=true, + escapeinside={\%*}{*)}, + linewidth=\textwidth, + basewidth=0.5em + } +--- + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..435169e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pandoc-include \ No newline at end of file