Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ab6459 committed May 3, 2024
0 parents commit a04e7e2
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
3 changes: 3 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Configuration:
GIT_REPO_LINK = "http://github.coventry.ac.uk/4017CMD-23-24/STUDENTID_IPA_A1"
STUDENT_ID = 123456789
32 changes: 32 additions & 0 deletions create_submission_document.py
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions header.yml
Original file line number Diff line number Diff line change
@@ -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
}
---

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pandoc-include

0 comments on commit a04e7e2

Please sign in to comment.