Commit 79aee4f3998254f9b1f891a35135029bcdfdcf7f

Authored by Miguel Barão
1 parent 504cbd8d
Exists in master and in 1 other branch dev

update README.md

Showing 2 changed files with 86 additions and 76 deletions   Show diff stats
README.md
1 1 # Getting Started
2 2  
  3 +Latest review: 2021-07-08
3 4  
4 5 ## Installation
5 6  
6 7 To complete the installation we will need to perform the following steps:
7 8  
8   -1. install python3.7, pip and npm
9   -1. download aprendizations from the repository
10   -1. install javascript libraries (with npm)
11   -1. install aprendizations (with pip)
12   -1. generate SSL certificates
13   -1. configure the firewall (optional)
  9 +1. install python3, pip and npm
  10 +2. download aprendizations from the repository
  11 +3. install javascript libraries (with npm)
  12 +4. install aprendizations (with pip)
  13 +5. generate SSL certificates
  14 +6. configure the firewall (optional)
14 15  
15 16 To use the software we need to:
16 17  
17 18 1. initialize database
18   -1. go to the demo directory (or an existing course)
19   -1. run `aprendizations demo.yaml`
  19 +2. go to the demo directory (or an existing course)
  20 +3. run `aprendizations demo.yaml`
20 21  
21 22 Each of these steps is explained below.
22 23  
23   -### Install python3.7 with sqlite3 support and npm
  24 +### Install python3 with sqlite3 support and npm
24 25  
25   -Python can be installed either from the system package management or compiled from sources.
  26 +Python can be installed either from the system package management or compiled
  27 +from sources.
26 28  
27 29 #### Installing from the system package manager
28 30  
29 31 ```sh
30   -sudo apt install python3.7 npm # Linux (Ubuntu)
31   -sudo pkg install python37 py37-sqlite3 npm # FreeBSD
32   -sudo port install python37 npm6 # MacOS
  32 +sudo pkg install python3 npm # FreeBSD
  33 +sudo apt install python3 npm # Linux (Ubuntu)
  34 +sudo port install python38 npm7 # MacOS
33 35 ```
34 36  
35   -#### Installing from source
  37 +In FreeBSD also install `py3X-sqlite3` where `X` is the python version.
  38 +
  39 +#### Installing from source (outdated)
36 40  
37 41 Make sure that the build tools and libraries are installed:
38 42  
39 43 ```sh
40 44 # Ubuntu:
41   -sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev
  45 +sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev \
  46 + libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev \
  47 + libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev
42 48 ```
43 49  
44   -Download python from [http://www.python.org]() and
  50 +Download [python](http://www.python.org) and
45 51  
46 52 ```sh
47 53 tar xvfJ Python-3.7.tar.xz
... ... @@ -50,30 +56,25 @@ cd Python-3.7
50 56 make && make install
51 57 ```
52 58  
53   -This will install python locally under `~/.local/bin`. Make sure to add it to your `PATH` in `~/.profile`. If `~/bin` is already in the path, you may just make a symbolic link `ln -s ~/.local/bin ~/bin`.
  59 +This will install python locally under `~/.local/bin`. Make sure to add it to
  60 +your `PATH` in `~/.profile`. If `~/bin` is already in the path, just make a
  61 +symbolic link `ln -s ~/.local/bin ~/bin`.
54 62  
55 63 ### Install pip
56 64  
57   -Python usually includes pip which is accessible through `python -m pip install something`, but it's also convenient to have the `pip` command directly available in the terminal.
58   -To install `pip` from the system package manager:
59   -
60   -```sh
61   -sudo apt install python3.7-pip # Ubuntu 19.04+
62   -sudo pkg py37-pip # FreeBSD
63   -sudo port install py37-pip # MacOS
64   -```
65   -
66   -otherwise run:
  65 +Install `pip` from the system package manager:
67 66  
68 67 ```sh
69   -python3.7 -m pip install pip # install in user area
  68 +sudo apt install python3-pip # Ubuntu
  69 +sudo pkg py38-pip # FreeBSD
  70 +sudo port install py39-pip # MacOS
70 71 ```
71 72  
72   -The latter will install `pip` in your user account under `~/.local/bin`.
73   -In the end you should be able to run `pip --version` and
74   -`python3 -c "import sqlite3"` without errors.
75   -Sometimes the `pip` command is named `pip3`,
76   -`pip3.7` or `pip-3.7`.
  73 +Then run `python3 -m pip install -U pip` to install latest version into your
  74 +user account under `~/.local/bin`.
  75 +In the end you should be able to run `pip --version` and `python3 -c "import
  76 +sqlite3"` without errors.
  77 +In some systems, `pip` can be named `pip3`, `pip3.8` or `pip-3.8`.
77 78  
78 79 Edit the configuration file `~/.config/pip/pip.conf` (FreeBSD, Linux) or
79 80 `Library/Application Support/pip/pip.conf` (MacOS) and add the lines
... ... @@ -85,7 +86,7 @@ user = yes
85 86  
86 87 This will set pip to install modules in the user area (recommended).
87 88  
88   -### Download and install aprendizations:
  89 +### Download and install aprendizations
89 90  
90 91 ```sh
91 92 git clone https://git.xdi.uevora.pt/mjsb/aprendizations.git
... ... @@ -94,20 +95,23 @@ npm install # install javascript libraries
94 95 pip install . # install aprendizations and dependencies
95 96 ```
96 97  
97   -Javascript libraries are installed in `aprendizations/node_modules` and are linked from `aprendizations/aprendizations/static`.
  98 +Javascript libraries are installed in `aprendizations/node_modules` and are
  99 +linked from `aprendizations/aprendizations/static`.
98 100  
99 101 Python packages are usually installed in:
100 102  
101   -- `~/.local/lib/python3.7/site-packages/` in Linux/FreeBSD.
102   -- `~/Library/python/3.7/lib/python/site-packages/` in MacOS.
  103 +* `~/.local/lib/python3.8/site-packages/` in Linux/FreeBSD.
  104 +* `~/Library/python/3.9/lib/python/site-packages/` in MacOS.
103 105  
104   -When aprendizations is installed with pip, all the dependencies are also installed. The javascript libraries previously installed with npm are copied to the above directory and the cloned repository is no longer needed.
  106 +When aprendizations is installed with pip, all the dependencies are also
  107 +installed. The javascript libraries previously installed with npm are copied to
  108 +the above directory and the cloned repository is no longer needed.
105 109  
106 110 At this point `aprendizations` is installed in
107 111  
108 112 ```sh
109 113 ~/.local/bin # Linux/FreeBSD
110   -~/Library/Python/3.7/bin # MacOS
  114 +~/Library/Python/3.9/bin # MacOS
111 115 ```
112 116  
113 117 and can be run from the terminal:
... ... @@ -119,10 +123,12 @@ aprendizations --help
119 123  
120 124 ### SSL Certificates
121 125  
122   -We need certificates for https. Certificates can be self-signed or validated by a trusted authority.
  126 +We need certificates for https. Certificates can be self-signed or validated by
  127 +a trusted authority.
123 128  
124 129 Self-signed can be used locally for development and testing, but browsers will
125   -complain. LetsEncrypt issues trusted and free certificates, but the server must have a registered publicly accessible domain name.
  130 +complain. LetsEncrypt issues trusted and free certificates, but the server must
  131 +have a registered publicly accessible domain name.
126 132  
127 133 #### Generating selfsigned certificates
128 134  
... ... @@ -137,18 +143,21 @@ openssl req -x509 -newkey rsa:4096 -keyout privkey.pem -out cert.pem -days 365 -
137 143 Install the certbot from LetsEncrypt:
138 144  
139 145 ```sh
140   -sudo pkg install py36-certbot # FreeBSD
  146 +sudo pkg install py38-certbot # FreeBSD
141 147 sudo apt install certbot # Ubuntu
142 148 ```
143 149  
144   -To generate or renew the certificates, ports 80 and 443 have to be accessible. **The firewall and webserver have to be stopped**.
  150 +To generate or renew the certificates, ports 80 and 443 must be accessible.
  151 +**Any firewall and webserver have to be stopped**.
145 152  
146 153 ```sh
147 154 sudo certbot certonly --standalone -d www.example.com # first time
148 155 sudo certbot renew # renew
149 156 ```
150 157  
151   -Certificates are saved under `/usr/local/etc/letsencrypt/live/www.example.com/`. Copy them to `~/.local/share/certs` and change permissions to be readable:
  158 +Certificates are saved under
  159 +`/usr/local/etc/letsencrypt/live/www.example.com/`. Copy them to
  160 +`~/.local/share/certs` and change permissions to be readable:
152 161  
153 162 ```sh
154 163 cd ~/.local/share/certs
... ... @@ -157,14 +166,13 @@ sudo cp /usr/local/etc/letsencrypt/live/www.example.com/privkey.pem .
157 166 chmod 400 cert.pem privkey.pem
158 167 ```
159 168  
160   -
161 169 ## Configuration
162 170  
163 171 ### Database
164 172  
165   -User data is maintained in a sqlite3 database which has to be created manually using the `initdb-aprendizations` command.
166   -The database file should be located in the same directory as the main
167   -YAML configuration file.
  173 +User data is maintained in a sqlite3 database which has to be created manually
  174 +using the `initdb-aprendizations` command. The database file should be located
  175 +in the same directory as the main YAML configuration file.
168 176  
169 177 For example, to run the included demo do:
170 178  
... ... @@ -180,10 +188,10 @@ initdb-aprendizations --help # for available options
180 188  
181 189 The default password is equal to the user name, if left undefined.
182 190  
183   -
184 191 ### Running the demo
185 192  
186   -The application includes a small example in `demo/demo.yaml` that can be used for initial testing. Run it with
  193 +The application includes a small example in `demo/demo.yaml` that can be used
  194 +for initial testing. Run it with
187 195  
188 196 ```sh
189 197 cd demo
... ... @@ -193,13 +201,14 @@ aprendizations demo.yaml
193 201 Open the browser at [https://127.0.0.1:8443](https://127.0.0.1:8443).
194 202 If everything looks good, check at the correct address
195 203 `https://www.example.com:8443`.
196   -The option `--debug` provides more verbose logging and might
197   -be useful during testing.
  204 +The option `--debug` provides more verbose logging and might be useful during
  205 +testing.
198 206  
199 207 ### Firewall configuration
200 208  
201   -Ports 80 and 443 are only usable by root. For security reasons the server runs as an unprivileged user on port 8443 for https.
202   -To access the server in the default https port (443), port forwarding can be configured in the firewall.
  209 +Ports 80 and 443 are only usable by root. For security reasons the server runs
  210 +as an unprivileged user on port 8443 for https. To access the server in the
  211 +default https port (443), port forwarding must be configured in the firewall.
203 212  
204 213 #### FreeBSD and pf
205 214  
... ... @@ -232,14 +241,14 @@ Reboot or `sudo service pf start`.
232 241  
233 242 Make sure the following steps have been done:
234 243  
235   -- installed python3.7, pip and npm
236   -- git-cloned the aprendizations from the main repository
237   -- installed javascript libraries with npm
238   -- installed aprendizations with pip
239   -- initialized database with at least 1 user
240   -- generate and copy certificates to the appropriate place
241   -- (optional) configure the firewall to do port forwarding
242   -- run `aprendizations demo.yaml --check`
  244 +* installed python3, pip and npm
  245 +* git-cloned the aprendizations from the main repository
  246 +* installed javascript libraries with npm
  247 +* installed aprendizations with pip
  248 +* initialized database with at least 1 user
  249 +* generate and copy certificates to the appropriate place
  250 +* (optional) configure the firewall to do port forwarding
  251 +* run `aprendizations demo.yaml --check`
243 252  
244 253 ## Keeping aprendizations updated
245 254  
... ... @@ -249,7 +258,7 @@ To update aprendizations to the latest version do:
249 258 cd aprendizations
250 259 git pull # get latest version
251 260 npm update # update javascript libraries
252   -pip install -U . # updates installed version to latest
  261 +pip install -U . # updates installed version
253 262 ```
254 263  
255 264 ## Troubleshooting
... ... @@ -261,16 +270,17 @@ errors in the browser.
261 270 Logging levels can be adjusted in `~/.config/aprendizations/logger.yaml` and
262 271 `~/.config/aprendizations/logger-debug.yaml`.
263 272  
264   -If these files do not yet exist, there are examples in `aprendizations/config` that can be copied to `~/.config/aprendizations`.
  273 +If these files do not yet exist, there are examples in `aprendizations/config`
  274 +that can be copied to `~/.config/aprendizations`.
265 275  
266   -#### UnicodeEncodeError
  276 +### UnicodeEncodeError
267 277  
268 278 The server should not generate this error, but when using external scripts to
269 279 generate questions or to correct, these scripts can print unicode strings to
270   -stdout. If the terminal does not support unicode, python will generate this
  280 +stdout. If the terminal does not support unicode, python will generate an
271 281 exception.
272 282  
273   -- FreeBSD fix: edit `~/.login_conf` to use UTF-8, for example:
  283 +* FreeBSD fix: edit `~/.login_conf` to use UTF-8, for example:
274 284  
275 285 ```sh
276 286 me:\
... ... @@ -278,10 +288,9 @@ me:\
278 288 :lang=en_US.UTF-8:
279 289 ```
280 290  
281   -- Debian fix: check `locale`...
  291 +* Debian fix: check `locale`...
282 292  
283   -
284   -#### The application runs but questions do not show up
  293 +### The application runs but questions do not show up
285 294  
286 295 Some operating systems have an option to disable animations to try to avoid
287 296 motion sickness in some people. Browsers will check this option with the OS and
... ... @@ -290,12 +299,11 @@ these will will not work and nothing is shown on the page.
290 299  
291 300 To fix this issue you need to allow animations in the Operating System:
292 301  
293   -- On windows 10, go to System Preferences, search for "Show animations in
  302 +* On windows 10, go to System Preferences, search for "Show animations in
294 303 windows" and turn it **ON**.
295   -- On MacOS or iOS search for reduced motion and switch it **OFF**
  304 +* On MacOS or iOS search for reduced motion and switch it **OFF**
296 305 (Preferences -> Acessibility -> Display -> Reduce motion).
297 306  
298   -
299 307 ## FAQ
300 308  
301 309 Common database manipulations:
... ... @@ -312,8 +320,10 @@ Some common database queries:
312 320 sqlite3 students.db "select distinct student_id from studenttopic"
313 321  
314 322 # How many topics has each student done?
315   -sqlite3 students.db "select student_id, count(topic_id) from studenttopic group by student_id order by count(topic_id) desc"
  323 +sqlite3 students.db "select student_id, count(topic_id) from studenttopic \
  324 + group by student_id order by count(topic_id) desc"
316 325  
317 326 # Which questions have more wrong answers?
318   -sqlite3 students.db "select count(ref), ref from answers where grade<1.0 group by ref order by count(ref) desc"
  327 +sqlite3 students.db "select count(ref), ref from answers where grade<1.0 \
  328 + group by ref order by count(ref) desc"
319 329 ```
... ...
mypy.ini
1 1 [mypy]
2   -python_version = 3.7
  2 +python_version = 3.8
3 3 warn_return_any = True
4 4 warn_unused_configs = True
5 5  
... ...