Commit e62cb00ea9774296f06b35a38dd799bfd8ccdb48
1 parent
0be0f447
Exists in
master
and in
1 other branch
- update README.md.
- minor changes in the code.
Showing
4 changed files
with
61 additions
and
33 deletions
Show diff stats
.gitignore
README.md
| ... | ... | @@ -17,39 +17,44 @@ The webserver is a python application and requires `python3.7` and `pip` to be i |
| 17 | 17 | - SQLAlchemy |
| 18 | 18 | - bcrypt |
| 19 | 19 | |
| 20 | -These can be installed for a single user (recommended), in a python virtual environment or system wide. | |
| 20 | +These can be installed for a single user, in a python virtual environment or system wide. | |
| 21 | 21 | |
| 22 | -#### Installing packages for a single user (recommended) | |
| 22 | +#### Installing packages for a single user | |
| 23 | 23 | |
| 24 | 24 | ```.bash |
| 25 | -pip3 install --user tornado mistune pyyaml pygments sqlalchemy bcrypt markdown | |
| 25 | +pip3 install --user tornado mistune pyyaml pygments sqlalchemy bcrypt | |
| 26 | 26 | ``` |
| 27 | 27 | |
| 28 | 28 | #### Installing packages in a virtual environment (alternative) |
| 29 | 29 | |
| 30 | 30 | ```bash |
| 31 | -pyvenv-3.6 venv/perguntations # or other virtualenv directory | |
| 32 | -source venv/perguntations/bin/activate # activate virtualenv | |
| 31 | +python3 -m venv PATH/TO/VENV/perguntations | |
| 32 | +source PATH/TO/VENV/perguntations/bin/activate # activate virtualenv | |
| 33 | 33 | |
| 34 | 34 | pip3 install tornado mistune pyyaml pygments sqlalchemy bcrypt markdown |
| 35 | 35 | ``` |
| 36 | 36 | |
| 37 | 37 | #### Installing packages system wide (alternative) |
| 38 | 38 | |
| 39 | -I personally prefer python packages to be installed for a single user, but if a system wide installation is required, it is probably better to use the operating system package manager instead of `pip`: | |
| 39 | +I personally prefer python packages to be installed for a single user, but if a system wide installation is required, the operating system package manager should be used: | |
| 40 | 40 | |
| 41 | 41 | Linux: |
| 42 | 42 | |
| 43 | 43 | ```bash |
| 44 | -apt-get install py37-tornado py37-mistune? py37-yaml py37-pygments... | |
| 44 | +apt install python3-tornado python3-mistune python3-yaml python3-pygments... | |
| 45 | 45 | ``` |
| 46 | 46 | |
| 47 | 47 | macOS macports: |
| 48 | 48 | |
| 49 | 49 | ```bash |
| 50 | -port install py37-py37-tornado py37-mistune? py37-yaml py37-pygments... | |
| 50 | +port install py37-tornado py37-mistune py37-yaml py37-pygments... | |
| 51 | 51 | ``` |
| 52 | 52 | |
| 53 | +FreeBSD: | |
| 54 | + | |
| 55 | +```bash | |
| 56 | +pkg install py37-tornado py37-mistune py37-yaml py37-pygments... | |
| 57 | +``` | |
| 53 | 58 | |
| 54 | 59 | ### 1.2 Install and setup perguntations |
| 55 | 60 | |
| ... | ... | @@ -65,6 +70,22 @@ where USERNAME is your account on bitbucket. |
| 65 | 70 | The server will run an https server and requires valid certificates. |
| 66 | 71 | To generate certificates, there are two possibilities: public server with static IP address or a private server. |
| 67 | 72 | |
| 73 | +The thirdparty javascript libraries are not included in the repository. They should be downloaded and installed in the directory perguntations/static/lib. | |
| 74 | + | |
| 75 | +The following libraries are currently necessary (as of 24/1/2019): | |
| 76 | + | |
| 77 | +``` | |
| 78 | +DataTables | |
| 79 | +MDB-Free_4 | |
| 80 | +MathJax-2.7.5 | |
| 81 | +bootstrap-4.2.1-dist | |
| 82 | +codemirror-5.42.2 | |
| 83 | +fontawesome-free-5.6.3-web | |
| 84 | +jquery-3.3.1.min.js | |
| 85 | +popper.min.js | |
| 86 | +``` | |
| 87 | + | |
| 88 | + | |
| 68 | 89 | #### Generating certificates for a public server (FreeBSD) |
| 69 | 90 | |
| 70 | 91 | ```sh |
| ... | ... | @@ -153,6 +174,7 @@ Ports 80 and 443 are reserved for the root user and and this software _should NO |
| 153 | 174 | |
| 154 | 175 | ```.bash |
| 155 | 176 | iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 8080 |
| 177 | +FIXME: also for port 443... | |
| 156 | 178 | ``` |
| 157 | 179 | |
| 158 | 180 | Explanation: |
| ... | ... | @@ -176,7 +198,9 @@ Edit `/etc/pf.conf`: |
| 176 | 198 | |
| 177 | 199 | or `ext_if="vtnet0"` for guest additions under virtual box. |
| 178 | 200 | |
| 179 | -Edit `rc.conf` | |
| 201 | +Start firewall with `sudo service pf start`. | |
| 202 | + | |
| 203 | +Optionally, to activate pf on boot, edit `rc.conf`: | |
| 180 | 204 | |
| 181 | 205 | pf_enable="YES" |
| 182 | 206 | pf_flags="" |
| ... | ... | @@ -187,11 +211,10 @@ Edit `rc.conf` |
| 187 | 211 | pflog_flags="" |
| 188 | 212 | pflog_logfile="/var/log/pflog" |
| 189 | 213 | |
| 190 | -Reboot. | |
| 191 | 214 | |
| 192 | 215 | ## Troubleshooting |
| 193 | 216 | |
| 194 | -* The server tries to run `python3.6` so this command must be accessible from user accounts. | |
| 217 | +* The server tries to run `python3` so this command must be accessible from user accounts. Currently, the minimum supported python version is 3.6. | |
| 195 | 218 | * If you are getting any `UnicodeEncodeError` type of errors that's because the terminal is not supporting UTF-8. This error may occur when a unicode character is printed to the screen by the server or, when running question generator or correction scripts, a message is piped between the server and the scripts that includes unicode characters. |
| 196 | 219 | Try running `locale` on the terminal and see if there are any error messages. Solutions: |
| 197 | 220 | - debian: fix it with `sudo dpkg-reconfigure locales`, select your UTF-8 locales and try again. |
| ... | ... | @@ -212,4 +235,4 @@ Try running `locale` on the terminal and see if there are any error messages. So |
| 212 | 235 | |
| 213 | 236 | ### Contacts ### |
| 214 | 237 | |
| 215 | -* Miguel Barão mjsb@uevora.pt | |
| 216 | 238 | \ No newline at end of file |
| 239 | +* Miguel Barão mjsb@uevora.pt | ... | ... |
models.py
| ... | ... | @@ -21,7 +21,10 @@ class Student(Base): |
| 21 | 21 | questions = relationship('Question', back_populates='student') |
| 22 | 22 | |
| 23 | 23 | def __repr__(self): |
| 24 | - return 'Student:\n id: "{0}"\n name: "{1}"\n password: "{2}"'.format(self.id, self.name, self.password) | |
| 24 | + return f'Student:\n\ | |
| 25 | + id: "{self.id}"\n\ | |
| 26 | + name: "{self.name}"\n\ | |
| 27 | + password: "{self.password}"' | |
| 25 | 28 | |
| 26 | 29 | |
| 27 | 30 | # --------------------------------------------------------------------------- |
| ... | ... | @@ -43,17 +46,17 @@ class Test(Base): |
| 43 | 46 | questions = relationship('Question', back_populates='test') |
| 44 | 47 | |
| 45 | 48 | def __repr__(self): |
| 46 | - return 'Test:\n\ | |
| 47 | - id: "{}"\n\ | |
| 48 | - ref="{}"\n\ | |
| 49 | - title="{}"\n\ | |
| 50 | - grade="{}"\n\ | |
| 51 | - state="{}"\n\ | |
| 52 | - comment="{}"\n\ | |
| 53 | - starttime="{}"\n\ | |
| 54 | - finishtime="{}"\n\ | |
| 55 | - filename="{}"\n\ | |
| 56 | - student_id="{}"\n'.format(self.id, self.ref, self.title, self.grade, self.state, self.comment, self.starttime, self.finishtime, self.filename, self.student_id) | |
| 49 | + return f'Test:\n\ | |
| 50 | + id: "{self.id}"\n\ | |
| 51 | + ref: "{self.ref}"\n\ | |
| 52 | + title: "{self.title}"\n\ | |
| 53 | + grade: "{self.grade}"\n\ | |
| 54 | + state: "{self.state}"\n\ | |
| 55 | + comment: "{self.comment}"\n\ | |
| 56 | + starttime: "{self.starttime}"\n\ | |
| 57 | + finishtime: "{self.finishtime}"\n\ | |
| 58 | + filename: "{self.filename}"\n\ | |
| 59 | + student_id: "{self.student_id}"\n' | |
| 57 | 60 | |
| 58 | 61 | |
| 59 | 62 | # --------------------------------------------------------------------------- |
| ... | ... | @@ -72,14 +75,14 @@ class Question(Base): |
| 72 | 75 | test = relationship('Test', back_populates='questions') |
| 73 | 76 | |
| 74 | 77 | def __repr__(self): |
| 75 | - return 'Question:\n\ | |
| 76 | - id: "{}"\n\ | |
| 77 | - ref: "{}"\n\ | |
| 78 | - grade: "{}"\n\ | |
| 79 | - starttime: "{}"\n\ | |
| 80 | - finishtime: "{}"\n\ | |
| 81 | - student_id: "{}"\n\ | |
| 82 | - test_id: "{}"\n'.fotmat(self.id, self.ref, self.grade, self.starttime, self.finishtime, self.student_id, self.test_id) | |
| 78 | + return f'Question:\n\ | |
| 79 | + id: "{self.id}"\n\ | |
| 80 | + ref: "{self.ref}"\n\ | |
| 81 | + grade: "{self.grade}"\n\ | |
| 82 | + starttime: "{self.starttime}"\n\ | |
| 83 | + finishtime: "{self.finishtime}"\n\ | |
| 84 | + student_id: "{self.student_id}"\n\ | |
| 85 | + test_id: "{self.test_id}"\n' | |
| 83 | 86 | |
| 84 | 87 | |
| 85 | 88 | # --------------------------------------------------------------------------- | ... | ... |
serve.py