randex 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: randex
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Create randomized multiple choice exams using latex.
5
5
  License: CC BY-NC 4.0
6
6
  Author: G. Arampatzis
@@ -39,16 +39,20 @@ Multiple exams can be created at once.
39
39
 
40
40
  ## Installation
41
41
 
42
- Randex requires Python version `3.10` or higher, `Poetry`, and `latexmk`.
42
+ Randex requires Python version `3.10` or higher and `latexmk`.
43
43
 
44
- ### Poetry
44
+ ### Randex
45
+
46
+ To install Randex, run the following command from the root folder of the project:
45
47
 
46
- [Poetry](https://python-poetry.org) is the packaging and dependency manager used for
47
- this project.
48
- To install Poetry, follow the instructions [here](https://python-poetry.org/docs/#installing-with-pipx).
48
+ ```sh
49
+ pip install randex
50
+ ```
49
51
 
50
52
  ### latexmk
51
53
 
54
+ In order to compile the LaTeX files, you need to install `latexmk`,
55
+
52
56
  From [here](https://mg.readthedocs.io/latexmk.html):
53
57
  ```
54
58
  Latexmk is a Perl script which you just have to run once and it does everything else for you... completely automagically.
@@ -57,41 +61,87 @@ Latexmk is a Perl script which you just have to run once and it does everything
57
61
  and [here](https://www.cantab.net/users/johncollins/latexmk/)
58
62
 
59
63
  ```
60
- Latexmk is also available at CTAN at https://ctan.org/pkg/latexmk/, and is/will be in the TeXLive and MiKTeX distributions.
64
+ Latexmk is also available at CTAN at https://ctan.org/pkg/latexmk/, and is/will be
65
+ in the TeXLive and MiKTeX distributions.
61
66
  ```
62
67
 
63
68
  If you have already `Latex` installed in your system, you will most
64
69
  probably have already `latexmk` installed as well.
65
70
 
66
- ### Randex
71
+ ## Randex Commands
67
72
 
68
- To install Randex, run the following command from the root folder of the project:
73
+ ### randex-download-examples
74
+
75
+ To download the latest examples from GitHub, run the following command from the root
76
+ folder of the project:
77
+
78
+ ```sh
79
+ randex-download-examples
80
+ ```
81
+
82
+ ### validate
83
+
84
+ This command validates a single question or all questions under a folder. Execute:
85
+
86
+ ```sh
87
+ validate -t examples/en/template-exam.yaml -o tmp --overwrite "examples/en/folder_*"
88
+ ```
89
+
90
+ to validate all the questions under the folder `examples/en` that contains subfolders
91
+ with questions.
92
+ It will use the configuration from the file `examples/en/template-exam.yaml`.
93
+ The LaTeX compilation will run inside the `temp` folder.
94
+ The `--clean` option will remove all intermediate files created by LaTeX,
95
+ and the `-a` flag will show the correct answers in the produced PDF.
96
+ Open the PDF file inside `temp` to validate that all questions appear correctly.
97
+
98
+ Run:
69
99
 
70
100
  ```sh
71
- poetry install
101
+ validate --help
72
102
  ```
73
103
 
74
- Then execute:
104
+ to see the help message for the command.
105
+
106
+ ### exams
107
+
108
+ To create a batch of exams with random questions, execute:
75
109
 
76
110
  ```sh
77
- poetry shell
111
+ exams -b 5 -n 2 -t examples/en/template-exam.yaml -o tmp --overwrite --clean "examples/en/folder_*"
78
112
  ```
79
113
 
80
- to spawn a shell with the Python environment activated.
114
+ This command will create 5 exams from using the questions inside the 3 folders with
115
+ names `folder_0`, `folder_1`, and `folder_2` using the configuration from the file
116
+ `examples/en/template-exam.yaml`.
117
+ The `--clean` option will remove all intermediate files created by LaTeX.
118
+ The `-n` option specifies the number of questions randomly chosen from each folder.
119
+ It can appear once, meaning all folders will contribute the same number of questions,
120
+ or multiple times, e.g., `-n 2 -n 1 -n 3 `, indicating the first folder will contribute
121
+ 2 questions, the second folder will contribute 1 question, and the third folder will
122
+ contribute 3 questions.
123
+ The `-b` option specifies the number of exams to create.
124
+
125
+ ### Grade
126
+
127
+ Not implemented yet.
81
128
 
82
129
  ## Randex Data Scheme
83
130
 
84
131
  Randex requires two types of data files to create the exams.
85
132
 
86
- ### Tex File
133
+ ### template-exam.yaml File
87
134
 
88
- The `Tex` file is a `YAML` file that describes the LaTeX file that will produce the exam. It contains the following keys:
135
+ The `template-exam.yaml` file is a `YAML` file that describes the LaTeX file that will
136
+ produce the exam. It contains the following keys:
89
137
 
90
- - `documentclass` (optional): String with the documentclass command of the file. Only the `exam` class is supported. Default:
138
+ - `documentclass` (optional): String with the documentclass command of the file.
139
+ Only the `exam` class is supported. Default:
91
140
  ```latex
92
141
  \documentclass[11pt]{exam}
93
142
  ```
94
- - `prebegin` (optional): String containing everything that goes before the `\begin{document}` command. Default:
143
+ - `prebegin` (optional): String containing everything that goes before the
144
+ `\begin{document}` command. Default:
95
145
  ```latex
96
146
  \usepackage{amsmath}
97
147
  \usepackage{amssymb}
@@ -117,7 +167,7 @@ The `Tex` file is a `YAML` file that describes the LaTeX file that will produce
117
167
 
118
168
  The right part of the head is reserved for the serial number of the exam.
119
169
 
120
- ### Questions File
170
+ ### questions.yaml File
121
171
 
122
172
  Each question is written in a `YAML` file with the following keys:
123
173
 
@@ -125,62 +175,11 @@ Each question is written in a `YAML` file with the following keys:
125
175
  - `answers` (required): List of strings with the answers. Do not use double quotes around the strings.
126
176
  - `right_answer` (required): Integer indicating the correct answer.
127
177
  The answer is non-negative and less than the length of the `answers` list.
128
- - `points` (optional): Points given to the question. Default: `1`
129
178
 
130
179
  The questions `YAML` files should be organized inside folders.
131
180
 
132
- The `randex` commands take the `Tex` file and the folders containing the exams as inputs.
133
-
134
- ## Randex Commands
135
-
136
- Inside an activated environment, you can run the following commands.
137
-
138
- ### Validate
181
+ The `randex` commands take the `template-exam.yaml` file and the folders containing the questions as inputs.
139
182
 
140
- This command validates a single question or all questions inside a folder. Execute:
141
-
142
- ```sh
143
- validate example/en -t example/en/tex.yaml -o temp --clean -a
144
- ```
145
-
146
- to validate all the questions inside the folder `example/en` that contains subfolders
147
- with questions.
148
- It will use the configuration from the file `example/en/tex.yaml`.
149
- The LaTeX compilation will run inside the `temp` folder.
150
- The `--clean` option will remove all intermediate files created by LaTeX,
151
- and the `-a` flag will show the correct answers in the produced PDF.
152
- Open the PDF file inside `temp` to validate that all questions appear correctly.
153
-
154
- Run:
155
-
156
- ```sh
157
- validate --help
158
- ```
159
-
160
- to see the help message for the command.
161
-
162
- ### Exams
163
-
164
- To create a batch of exams with random questions, execute:
165
-
166
- ```sh
167
- exams example/en/folder_0/ example/en/folder_1/ example/en/folder_2/ -b 10 -t example/en/tex.yaml --clean -n 2
168
- ```
169
-
170
- This command will create 10 exams from 3 folders using the configuration from the file
171
- `example/en/tex.yaml`.
172
- The `--clean` option will remove all intermediate files created by LaTeX.
173
- The `-n` option specifies the number of questions randomly chosen from each folder.
174
- It can appear once, meaning all folders will contribute the same number of questions,
175
- or multiple times, e.g., `-n 2 -n 1`, indicating the first folder will contribute
176
- 2 questions, and the remaining folders will contribute 1 question each.
177
- For example, `-n 2 -n 1 -n 3` means the first, second,
178
- and third folders will contribute 2, 1, and 3 questions, respectively.
179
- The `-b` option specifies the number of exams to create.
180
-
181
- ### Grade
182
-
183
- Not implemented yet.
184
183
 
185
184
 
186
185
  # License
@@ -0,0 +1,11 @@
1
+ randex/__init__.py,sha256=6bBAISO6MqVCSCvqLcK3SGUnDODuwobLWouO3GY8SRU,187
2
+ randex/exam.py,sha256=l-_6GnrstLgVMORXNEIKzgW9k6h_YbXndZd8YmEGKBI,26450
3
+ scripts/__init__.py,sha256=F8pjiW8AlL0IhnvVh1TEfgiD--YdFE_PggtSevHp5y4,38
4
+ scripts/exams.py,sha256=L4QSOZpU8Hw5QkW_2x5s8NESQAwlEmZTSaT6ZZ8-c04,3341
5
+ scripts/randex_download_examples.py,sha256=fj88XkZV8bpHPCeXu1f3nVNws_hbcJ_3Zso7XOPB0RQ,1682
6
+ scripts/validate.py,sha256=xruN1P1rgJnc0MTklLgSrsx9TcFC2SY1a9eksNT_-KM,2599
7
+ randex-0.2.0.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
8
+ randex-0.2.0.dist-info/METADATA,sha256=1KJfVvoQSFmykT68kvqLkq2YAiu6AxC5hdUSY15Fks0,6551
9
+ randex-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
+ randex-0.2.0.dist-info/entry_points.txt,sha256=RayNUArGNT0MLZi7uh1MHjnd1L1V4X6C4sBdMLbvAfc,138
11
+ randex-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  [console_scripts]
2
2
  exams=scripts.exams:main
3
+ randex-download-examples=scripts.randex_download_examples:main
3
4
  validate=scripts.validate:main
4
5
 
@@ -0,0 +1,57 @@
1
+ """Download the latest examples from GitHub."""
2
+
3
+ import io
4
+ import shutil
5
+ import sys
6
+ import tempfile
7
+ import urllib.request
8
+ import zipfile
9
+ from pathlib import Path
10
+ from urllib.error import URLError
11
+
12
+ GITHUB_ZIP_URL = "https://github.com/arampatzis/randex/archive/refs/heads/main.zip"
13
+ DEST_DIR = Path("examples")
14
+
15
+
16
+ def main() -> None:
17
+ """Download the latest examples from GitHub."""
18
+ print("📦 Downloading examples from GitHub...")
19
+
20
+ if DEST_DIR.exists():
21
+ print(
22
+ f"❌ Destination folder '{DEST_DIR}' already exists. "
23
+ "Please remove it first."
24
+ )
25
+ sys.exit(1)
26
+
27
+ try:
28
+ with (
29
+ urllib.request.urlopen(GITHUB_ZIP_URL) as response, # noqa: S310
30
+ zipfile.ZipFile(io.BytesIO(response.read())) as zip_ref,
31
+ ):
32
+ temp_dir = Path(tempfile.mkdtemp())
33
+ zip_ref.extractall(temp_dir)
34
+
35
+ # Detect the root folder inside the zip (e.g., randex-main)
36
+ root_entry = next((p for p in temp_dir.iterdir() if p.is_dir()), None)
37
+
38
+ if not root_entry:
39
+ print("❌ Could not locate the root folder in the archive.")
40
+ sys.exit(1)
41
+
42
+ examples_path = root_entry / "examples"
43
+
44
+ if not examples_path.exists():
45
+ print("❌ examples/ folder not found in the downloaded repository.")
46
+ sys.exit(1)
47
+
48
+ shutil.copytree(examples_path, DEST_DIR)
49
+ print(f"✅ Examples downloaded to: {DEST_DIR.resolve()}")
50
+
51
+ except (URLError, zipfile.BadZipFile, OSError, shutil.Error) as e:
52
+ print(f"❌ Error: {e}")
53
+ sys.exit(1)
54
+
55
+
56
+ if __name__ == "__main__":
57
+ main()
@@ -1,10 +0,0 @@
1
- randex/__init__.py,sha256=6bBAISO6MqVCSCvqLcK3SGUnDODuwobLWouO3GY8SRU,187
2
- randex/exam.py,sha256=l-_6GnrstLgVMORXNEIKzgW9k6h_YbXndZd8YmEGKBI,26450
3
- scripts/__init__.py,sha256=F8pjiW8AlL0IhnvVh1TEfgiD--YdFE_PggtSevHp5y4,38
4
- scripts/exams.py,sha256=L4QSOZpU8Hw5QkW_2x5s8NESQAwlEmZTSaT6ZZ8-c04,3341
5
- scripts/validate.py,sha256=xruN1P1rgJnc0MTklLgSrsx9TcFC2SY1a9eksNT_-KM,2599
6
- randex-0.1.0.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
7
- randex-0.1.0.dist-info/METADATA,sha256=7UQ_rkrBEjHg9pKOjqMKrSRcv4S8FjjGLS7zgmEmG-g,6677
8
- randex-0.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
9
- randex-0.1.0.dist-info/entry_points.txt,sha256=gRD7WCYtG4hW2sv_mg2TT7ifbCGjqNqMBezaUa32F64,75
10
- randex-0.1.0.dist-info/RECORD,,
File without changes