Commit 332f9e64 authored by Christian Rohlfing's avatar Christian Rohlfing
Browse files

renamed preparemoodle and preparepdf

parent 6a45642b
Pipeline #457954 passed with stage
in 1 minute and 53 seconds
......@@ -4,14 +4,14 @@ Preparing exam scans for ship out: Adding watermarks, encryption and preparing u
## Contents
* `preparepdf.py` unzips files from submission zip file downloadable from Moodle(in case there are no scans) and renames it accordingly in the format (`<Matriculation number>_<Lastname>`)
* `handlemoodlesubmissions.py` unzips files from submission zip file downloadable from Moodle(in case there are no scans) and renames it accordingly in the format (`<Matriculation number>_<Lastname>`)
* `supplements.py` renames and create copies of sample solutions(if any) for every student
* `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
* `preparemoodleupload.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.
Please note that the three scripts `watermark.py`, `encrypt.py`, and `preparemoodleupload.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](Dependancies.md).
Exemplary outputs can be downloaded:
......@@ -89,7 +89,7 @@ docker run --name examscan --rm -v $(pwd):$(pwd) -w $(pwd) examscan:latest batch
### Process
Run `preparepdf.py` (if you have submissions in a zip and not as scans), `supplements.py` (if you want to add watermarked sample solutions as well), `watermark.py`, `encrypt.py`, and `preparemoodle.py` (or run `batch.py` which runs all) as described in the sections below. In summary, these steps will
Run `handlemoodlesubmissions.py` (if you have submissions in a zip and not as scans), `supplements.py` (if you want to add watermarked sample solutions as well), `watermark.py`, `encrypt.py`, and `preparemoodleupload.py` (or run `batch.py` which runs all) as described in the sections below. In summary, these steps will
1. unzip all PDF files from the zip and rename them according to the schema `<Matriculation number>_<Lastname>`
1. prepare sample solution for each students
......@@ -111,7 +111,7 @@ Please note that the following commands may only work for you with either `pytho
Assuming that ./submissions.zip is the zip file containing all submissions and ./Bewertungen.csv is the grading worksheet
```bash
python preparepdf.py --inzip ./submissions.zip --outfolder ./pdfs --csv ./Bewertungen.csv
python handlemoodlesubmissions.py --inzip ./submissions.zip --outfolder ./pdfs --csv ./Bewertungen.csv
```
#### Prepare copies of Sample Solutions for each student (Optional)
......@@ -164,7 +164,7 @@ This step prepares the PDFs for upload to Moodle. First, the grading table `Bewe
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`.
```bash
python preparemoodle.py --in ./pdfs_encrypted --csv ./Bewertungen.csv --out ./moodle_feedbacks.zip
python preparemoodleupload.py --in ./pdfs_encrypted --csv ./Bewertungen.csv --out ./moodle_feedbacks.zip
```
Then, you can upload `moodle_feedbacks.zip` in Moodle:
......@@ -173,7 +173,7 @@ Then, you can upload `moodle_feedbacks.zip` in Moodle:
Further remarks:
* Exemplary zip archive `moodle_feedbacks.zip` can be downloaded [here](https://git.rwth-aachen.de/IENT/exam-scan/-/jobs/artifacts/master/download?job=test).
* You can also conduct a dry run (neither folders nor zip file are created) via `./preparemoodle.sh --dry [...]`
* You can also conduct a dry run (neither folders nor zip file are created) via `./preparemoodleupload.sh --dry [...]`
#### Batch job
......
......@@ -16,11 +16,11 @@ import argparse
import utils.moodle as moodle
import preparepdf
import handlemoodlesubmissions
import supplements
import watermark
import encrypt
import preparemoodle
import preparemoodleupload
def _make_parser():
......@@ -91,7 +91,7 @@ def main(args):
if inzip != "0":
if not os.path.exists(infolder):
os.makedirs(infolder)
preparepdf.main([
handlemoodlesubmissions.main([
inzip, csv, infolder,
'--csvenc', csv_enc, '--csvdelim', csv_delim,
'--csvquote', csv_quote])
......@@ -134,7 +134,7 @@ def main(args):
if not os.path.exists(moodle_tmp):
os.makedirs(moodle_tmp)
preparemoodle.main([
preparemoodleupload.main([
enc_out, csv, moodle_out,
'--tmp', moodle_tmp, '--csvenc', csv_enc, '--csvdelim', csv_delim,
'--csvquote', csv_quote])
......
......@@ -16,6 +16,6 @@ Note that all Python packages are listed in the file `requirements.txt`.
* pwgen 0.8.2.post0
* pikepdf 2.5.0
## `preparemoodle.py`
## `preparemoodleupload.py`
* zip
......@@ -40,8 +40,8 @@ if __name__ == '__main__':
{'file': 'watermark', 'title': 'Watermark'},
{'file': 'batch', 'title': 'Batch'},
{'file': 'encrypt', 'title': 'Encrypt'},
{'file': 'preparemoodle', 'title': 'Prepare Moodle'},
{'file': 'preparepdf', 'title': 'Prepare PDFs'},
{'file': 'preparemoodleupload', 'title': 'Prepare Moodle Upload'},
{'file': 'handlemoodlesubmissions', 'title': 'Handle Moodle Submission'},
{'file': 'renamescans', 'title': 'Rename Scans'},
{'file': 'supplements', 'title': 'Supplements'},
]
......
Handle Moodle Submission
************************
.. toctree::
:maxdepth: 3
.. autoprogram:: handlemoodlesubmissions:_parser
:prog: handlemoodlesubmissions.py
API
===
.. automodule:: handlemoodlesubmissions
:members:
......@@ -7,8 +7,8 @@ Welcome to Exam Scan's documentation!
encrypt
preparemoodle
preparepdf
preparemoodleupload
handlemoodlesubmissions
renamescans
supplements
watermark
......
Prepare Moodle
**************
.. toctree::
:maxdepth: 3
.. autoprogram:: preparemoodle:_parser
:prog: preparemoodle.py
API
===
.. automodule:: preparemoodle
:members:
Prepare Moodle Upload
*********************
.. toctree::
:maxdepth: 3
.. autoprogram:: preparemoodleupload:_parser
:prog: preparemoodleupload.py
API
===
.. automodule:: preparemoodleupload
:members:
Prepare PDFs
************
.. toctree::
:maxdepth: 3
.. autoprogram:: preparepdf:_parser
:prog: preparepdf.py
API
===
.. automodule:: preparepdf
:members:
......@@ -27,7 +27,7 @@ def _make_parser():
parser = argparse.ArgumentParser(
parents=[csv_parser],
description=__doc__, prog='preparepdf.py',
description=__doc__, prog='handlemoodlesubmissions.py',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
......
......@@ -147,7 +147,7 @@ def sanity_check(matnums_csv, matnums_folder):
def _make_parser():
csv_parser = moodle.get_moodle_csv_parser()
parser = argparse.ArgumentParser(
parents=[csv_parser], prog='preparemoodle.py',
parents=[csv_parser], prog='preparemoodleupload.py',
description=__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
......
......@@ -16,7 +16,7 @@ class MainTest(unittest.TestCase):
print('Time: %.3f' % (t))
def test_copy_from_zip(self):
import preparepdf
import handlemoodlesubmissions
expected_files = [
'123001_L.pdf',
......@@ -35,7 +35,7 @@ class MainTest(unittest.TestCase):
os.mkdir(tmp_dir)
# Call function
preparepdf.main([
handlemoodlesubmissions.main([
in_zip, sheet_csv, out_dir, "-t", tmp_dir])
# Assert output
......
......@@ -18,8 +18,8 @@ class MainTest(unittest.TestCase):
# Clean up
shutil.rmtree(self.test_dir)
def test_preparemoodle_single(self):
import preparemoodle
def test_preparemoodleupload_single(self):
import preparemoodleupload
expected_feedback_folder =\
'LastnameB, FirstnameB_1519322_assignsubmission_file_'
......@@ -36,7 +36,7 @@ class MainTest(unittest.TestCase):
out_zip = os.path.join(self.test_dir, feedback_zip)
# Call function
preparemoodle.main([in_dir, sheet_csv, out_zip,
preparemoodleupload.main([in_dir, sheet_csv, out_zip,
"-t", tmp_dir])
# Unpack feedbacks
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment