Commit 5351f71f8ac14c9c3b7298de6025fdaf8e0058b1
1 parent
f4aa081d
Exists in
dev
minor
Showing
2 changed files
with
27 additions
and
25 deletions
Show diff stats
README.md
... | ... | @@ -11,14 +11,14 @@ |
11 | 11 | |
12 | 12 | ## Requirements |
13 | 13 | |
14 | -The webserver is a python application that requires `>=python3.8` and the | |
14 | +The web server is a python application that requires `>=python3.11` and the | |
15 | 15 | package installer for python `pip`. The node package management `npm` is also |
16 | -necessary in order to install the javascript libraries. | |
16 | +necessary in order to install javascript libraries. | |
17 | 17 | |
18 | 18 | ```sh |
19 | 19 | sudo apt install python3 python3-pip npm # Ubuntu |
20 | -sudo pkg install python38 py38-sqlite3 py38-pip npm # FreeBSD | |
21 | -sudo port install python38 py38-pip py38-setuptools npm6 # MacOS (macports) | |
20 | +sudo pkg install python py311-sqlite3 py311-pip npm # FreeBSD | |
21 | +sudo port install python312 py312-pip py312-setuptools npm10 # MacOS (macports) | |
22 | 22 | ``` |
23 | 23 | |
24 | 24 | To make the `pip` install packages to a local directory, the file `pip.conf` | ... | ... |
perguntations/testfactory.py
... | ... | @@ -9,7 +9,8 @@ import random |
9 | 9 | import logging |
10 | 10 | |
11 | 11 | # other libraries |
12 | -import schema | |
12 | +# import schema | |
13 | +from schema import And, Or, Optional, Regex, Schema, Use | |
13 | 14 | |
14 | 15 | # this project |
15 | 16 | from .questions import QFactory, QuestionException, QDict |
... | ... | @@ -41,34 +42,35 @@ def check_import_files(files: list) -> bool: |
41 | 42 | return True |
42 | 43 | |
43 | 44 | |
44 | -def normalize_question_list(questions: list) -> None: | |
45 | - """convert question ref from string to list of string""" | |
46 | - for question in questions: | |
47 | - if isinstance(question["ref"], str): | |
48 | - question["ref"] = [question["ref"]] | |
49 | - | |
50 | - | |
51 | -test_schema = schema.Schema( | |
45 | +test_schema = Schema( | |
52 | 46 | { |
53 | - "ref": schema.Regex("^[a-zA-Z0-9_-]+$"), | |
54 | - "database": schema.And(str, path.isfile), | |
55 | - "answers_dir": schema.And(str, check_answers_directory), | |
47 | + "ref": Regex("^[a-zA-Z0-9_-]+$"), | |
48 | + "database": And(str, path.isfile), | |
49 | + "answers_dir": Use(check_answers_directory), | |
56 | 50 | "title": str, |
57 | - schema.Optional("duration"): int, | |
58 | - schema.Optional("autosubmit"): bool, | |
59 | - schema.Optional("autocorrect"): bool, | |
60 | - schema.Optional("show_points"): bool, | |
61 | - schema.Optional("scale"): schema.And( | |
62 | - [schema.Use(float)], lambda s: len(s) == 2 | |
63 | - ), | |
64 | - "files": schema.And([str], check_import_files), | |
65 | - "questions": [{"ref": schema.Or(str, [str]), schema.Optional("points"): float}], | |
51 | + Optional("duration"): int, | |
52 | + Optional("autosubmit"): bool, | |
53 | + Optional("autocorrect"): bool, | |
54 | + Optional("show_points"): bool, | |
55 | + Optional("scale"): And([Use(float)], lambda s: len(s) == 2), | |
56 | + "files": And([str], check_import_files), | |
57 | + "questions": [{ | |
58 | + "ref": Or(str, [str]), | |
59 | + Optional("points"): float | |
60 | + }], | |
66 | 61 | }, |
67 | 62 | ignore_extra_keys=True, |
68 | 63 | ) |
69 | 64 | # FIXME: schema error with 'testfile' which is added in the code |
70 | 65 | |
71 | 66 | # ============================================================================ |
67 | +def normalize_question_list(questions: list) -> None: # FIXME: move inside the class? | |
68 | + """convert question ref from string to list of string""" | |
69 | + for question in questions: | |
70 | + if isinstance(question["ref"], str): | |
71 | + question["ref"] = [question["ref"]] | |
72 | + | |
73 | + | |
72 | 74 | class TestFactoryException(Exception): |
73 | 75 | """exception raised in this module""" |
74 | 76 | ... | ... |
-
mentioned in commit cc91e4c034aa4336bad33042438dd98d4f20d958