exam-scan
Preparing exam scans for ship out: Adding watermarks, encryption and preparing upload to Moodle.
Contents
-
watermark.py
watermarks each page of PDFs containing exam scans with matriculation number of the respective student -
encrypt.py
encrypts PDF with password either with a common password(passed as an argument) or a randomly generated password(when there is no argument) -
preparemoodle.py
prepares for uploading PDFs to moodle via assign module as feedback file for each student -
batch.py
executes all three programs as a singular batch job
Please note that the three scripts watermark.py
, encrypt.py
, and preparemoodle.py
do not depend on each other.
If you want to use only a subset (or one) of the scripts, you can find it here.
Exemplary outputs can be downloaded:
- moodle_feedbacks.zip: The zip-Archive to be uploaded to Moodle containing the watermarked and encrypted PDFs for each student.
- passwords.csv: CSV file containing passwords for each PDF.
Instructions
Prerequisites
-
Create PDFs corresponding to each exam
- Scan the exams and save the scans as PDFs (each page should be A4). For most copy machines, you can save an A3 scan (double page of an exam) as two A4 pages.
- The filename of each PDF should start with the student's matriculation number (e.g.
123456_Nachname.pdf
). - Place all PDFs in a folder, e.g.
pdfs
.
-
Create and setup Moodle
- In your Moodle course room, create an
assign
module following this guideline - Download the grading table
Bewertungen.csv
from Moodle via:Alle Angaben anzeigen
→Bewertungsvorgang
→Bewertungstabelle herunterladen
- In your Moodle course room, create an
-
Install the software dependancies
The current version of code was tested on Windows10, Ubuntu 20.04.1 LTS and macOS 10.14 Mojave to ensure platform independance.The code has the following software dependencies which needs to installed before the programs can be run successfully. Specific version numbers along with categorisation based on script requirement is available here:
- Imagemagick
- Ghostscript
- Python 3.8/3.9
- PIP
- Additional Python modules:
- wand
- pillow
- PyPDF2
- pwgen
- pikepdf
Instructions to install software dependencies based on your operating system:
- Windows 10 : Installation of Software Dependencies
- MacOS : Installation of Software Dependencies
- Linux : Installation of Software Dependencies
Scripts and how to run them
Process
Run watermark.py
, encrypt.py
, and preparemoodle.py
(or run batch.py
which runs all three) as described in the sections below. In summary, these steps will
- watermark each page of each PDF with the corresponding matriculation number,
- encrypt each PDF with a password (global or per-student) and
- construct a zip-archive enabling batch upload and assignment of each PDF to each student in Moodle.
Upload moodle_feedbacks.zip
to Moodle
-
Alle Angaben anzeigen
→Bewertungsvorgang
→Mehrere Feedbackdateien in einer Zip-Datei hochladen
- Moodle will check for consistency and prompt errors.
Commands
Watermark
We assume that the folder ./pdfs
holds the scans of the exams.
The filename of each PDF should start with the matriculation number of the student, e.g. ./pdfs/123456_Lastname.pdf
.
python watermark.py --in ./pdfs --out ./pdfs_watermarked --cores 2
or
python3 watermark.py --in ./pdfs --out ./pdfs_watermarked --cores 2
Folder pdfs_watermarked
contains watermarked PDFs, with each page watermarked with the matriculation number of the student.
Encrypt
Use either a global password by specifying it with the --password
option or per-student passwords by ommiting --password
.
python encrypt.py --in ./pdfs_watermarked --out ./pdfs_encrypted --password ganzgeheim
or
python3 encrypt.py --in ./pdfs_watermarked --out ./pdfs_encrypted --password ganzgeheim
Folder ./pdfs_encrypted
contains all encrypted PDFs as well as passwords.csv
, mapping the password of each PDF to the matriculation number.
Prepare for Moodle batch upload
This step prepares the PDFs for upload to Moodle. First, the grading table Bewertungen.csv
has to be downloaded from Moodle via:
Alle Angaben anzeigen
→ Bewertungsvorgang
→ Bewertungstabelle herunterladen
.
This step is needed since Moodle does not only need matriculation number, but also last and first name as well as an internal user id, which is stored in Bewertungen.csv
.
python preparemoodle.py --in ./pdfs_encrypted --csv ./Bewertungen.csv --out ./moodle_feedbacks.zip
or
python3 preparemoodle.py --in ./pdfs_encrypted --csv ./Bewertungen.csv --out ./moodle_feedbacks.zip
Then, you can upload moodle_feedbacks.zip
in Moodle:
Alle Angaben anzeigen
→ Bewertungsvorgang
→ Mehrere Feedbackdateien in einer Zip-Datei hochladen
Further remarks:
- Exemplary zip archive
moodle_feedbacks.zip
can be downloaded here. - You can also conduct a dry run (neither folders nor zip file are created) via
./preparemoodle.sh --dry [...]
Batch job
Or do everything in one step
python batch.py --in ./pdfs --out ./out --cores 2 --password ganzgeheim --csv ./Bewertungen.csv
or
python3 batch.py --in ./pdfs --out ./out --cores 2 --password ganzgeheim --csv ./Bewertungen.csv
with folder out
containing passwords.csv
and moodle_feedbacks.zip
.
Original Authors
Helmut Flasche, Jens Schneider, Christian Rohlfing, IENT RWTH Aachen
Dietmar Kahlen, ITHE RWTH Aachen
Amrita Deb, IT Center, RWTH Aachen University
Who do I talk to?
Servicedesk IT-Center RWTH Aachen <servicedesk@itc.rwth-aachen.de>
If you have any errors or problems while running the programs, make sure to first check if your error is listed in FAQs