43785de6
Miguel Barão
- added documenta...
|
1
|
# Getting Started
|
a96cd2c7
Miguel Barão
- added logging s...
|
2
|
|
1e8f0810
Miguel Barão
update setup.py a...
|
3
|
Latest review: 2023-04-05
|
5d859a41
Miguel Barão
update documentation
|
4
5
6
|
## Installation
|
93e13002
Miguel Barão
updates README.md.
|
7
|
To complete the installation we will need to perform the following steps:
|
a96cd2c7
Miguel Barão
- added logging s...
|
8
|
|
39126690
Miguel Barão
removes npm and n...
|
9
10
11
12
|
1. install python3 and pip
2. install aprendizations
3. generate SSL certificates
4. configure the firewall (optional)
|
f540e673
Miguel Barão
- added README.md
|
13
|
|
5d859a41
Miguel Barão
update documentation
|
14
15
|
To use the software we need to:
|
39126690
Miguel Barão
removes npm and n...
|
16
|
1. initialize a database
|
443a1eea
Miguel Barão
Update to latest ...
|
17
|
2. go to the demo directory (or an existing course)
|
39126690
Miguel Barão
removes npm and n...
|
18
|
3. run `aprendizations courses.yaml`
|
5d859a41
Miguel Barão
update documentation
|
19
20
|
Each of these steps is explained below.
|
43785de6
Miguel Barão
- added documenta...
|
21
|
|
39126690
Miguel Barão
removes npm and n...
|
22
|
### Install python with sqlite3 and pip support
|
43785de6
Miguel Barão
- added documenta...
|
23
|
|
39126690
Miguel Barão
removes npm and n...
|
24
25
|
Minimum supported version is python3.9. The installed versions depend on the
operating system default.
|
c54ee176
Miguel Barão
update javascript...
|
26
27
|
```sh
|
39126690
Miguel Barão
removes npm and n...
|
28
29
|
sudo pkg install python3 py39-sqlite3 py39-pip # FreeBSD
sudo apt install python3 python3-pip # Linux (Ubuntu)
|
1e8f0810
Miguel Barão
update setup.py a...
|
30
|
sudo port install python311 py311-pip # MacOS
|
93e13002
Miguel Barão
updates README.md.
|
31
32
|
```
|
43785de6
Miguel Barão
- added documenta...
|
33
|
In the end you should be able to run `python3 -m pip --version` and `python3 -c
|
59213008
Miguel Barão
- fixed user path...
|
34
|
"import sqlite3"` without errors.
|
443a1eea
Miguel Barão
Update to latest ...
|
35
|
|
a96cd2c7
Miguel Barão
- added logging s...
|
36
|
Packages should **not** be installed system-wide. Either install them to a
|
43785de6
Miguel Barão
- added documenta...
|
37
|
python virtual environment or in the user area. To install in the user area use
|
39126690
Miguel Barão
removes npm and n...
|
38
39
|
```sh
|
1e8f0810
Miguel Barão
update setup.py a...
|
40
|
python3 -m pip install --user some_package
|
43785de6
Miguel Barão
- added documenta...
|
41
|
```
|
f540e673
Miguel Barão
- added README.md
|
42
|
|
443a1eea
Miguel Barão
Update to latest ...
|
43
44
|
### Install aprendizations
|
39126690
Miguel Barão
removes npm and n...
|
45
|
```sh
|
5d859a41
Miguel Barão
update documentation
|
46
|
python3 -m pip install git+https://git.xdi.uevora.pt/mjsb/aprendizations.git
|
1e8f0810
Miguel Barão
update setup.py a...
|
47
48
49
50
51
|
```
Python packages are usually installed in:
* `~/.local/lib/python3.9/site-packages/` in Linux/FreeBSD.
|
5dae401a
Miguel Barão
update README.md
|
52
|
* `~/Library/python/3.11/lib/python/site-packages/` in MacOS.
|
f540e673
Miguel Barão
- added README.md
|
53
|
|
43785de6
Miguel Barão
- added documenta...
|
54
55
56
57
|
When aprendizations is installed with pip, all the dependencies are also
installed.
At this point, the commands `aprendizations` and `initdb-aprendizations` are
|
f540e673
Miguel Barão
- added README.md
|
58
|
installed in
|
39126690
Miguel Barão
removes npm and n...
|
59
|
|
f540e673
Miguel Barão
- added README.md
|
60
|
```sh
|
43785de6
Miguel Barão
- added documenta...
|
61
|
~/.local/bin # Linux/FreeBSD
|
39126690
Miguel Barão
removes npm and n...
|
62
|
~/Library/Python/3.11/bin # MacOS
|
43785de6
Miguel Barão
- added documenta...
|
63
|
```
|
f540e673
Miguel Barão
- added README.md
|
64
|
|
c3eba869
Miguel Barão
update README.md
|
65
|
and can be run from the terminal:
|
a96cd2c7
Miguel Barão
- added logging s...
|
66
|
|
443a1eea
Miguel Barão
Update to latest ...
|
67
|
```sh
|
1e8f0810
Miguel Barão
update setup.py a...
|
68
|
aprendizations --version
|
a96cd2c7
Miguel Barão
- added logging s...
|
69
|
aprendizations --help
|
443a1eea
Miguel Barão
Update to latest ...
|
70
|
initdb-aprendizations --help
|
39126690
Miguel Barão
removes npm and n...
|
71
|
```
|
f540e673
Miguel Barão
- added README.md
|
72
|
|
39126690
Miguel Barão
removes npm and n...
|
73
74
|
### SSL Certificates
|
5dae401a
Miguel Barão
update README.md
|
75
76
|
We need certificates for https. Certificates can be self-signed or validated by
a trusted authority.
|
93e13002
Miguel Barão
updates README.md.
|
77
|
|
1e8f0810
Miguel Barão
update setup.py a...
|
78
|
Self-signed can be used locally for development and testing, but browsers will
|
5dae401a
Miguel Barão
update README.md
|
79
80
|
complain. LetsEncrypt issues trusted and free certificates, but the server must
have a registered publicly accessible domain name.
|
93e13002
Miguel Barão
updates README.md.
|
81
|
|
b4ceb7fc
Miguel Barão
minor change in l...
|
82
|
#### Generating selfsigned certificates
|
93e13002
Miguel Barão
updates README.md.
|
83
84
85
|
Generate a selfsigned certificate and place it in `~/.local/share/certs`.
|
39126690
Miguel Barão
removes npm and n...
|
86
|
```sh
|
93e13002
Miguel Barão
updates README.md.
|
87
|
openssl req -x509 -newkey rsa:4096 -keyout privkey.pem -out cert.pem -days 365 -nodes
|
f540e673
Miguel Barão
- added README.md
|
88
|
```
|
59213008
Miguel Barão
- fixed user path...
|
89
90
|
#### LetsEncrypt certificates
|
443a1eea
Miguel Barão
Update to latest ...
|
91
92
|
Install the certbot from LetsEncrypt:
|
c288f8c6
Miguel Barao
- updated documen...
|
93
|
|
443a1eea
Miguel Barão
Update to latest ...
|
94
95
96
|
```sh
sudo pkg install py39-certbot # FreeBSD
sudo apt install certbot # Ubuntu
|
c288f8c6
Miguel Barao
- updated documen...
|
97
|
```
|
93e13002
Miguel Barão
updates README.md.
|
98
|
|
f540e673
Miguel Barão
- added README.md
|
99
|
To generate or renew the certificates, ports 80 and 443 must be accessible.
|
b4ceb7fc
Miguel Barão
minor change in l...
|
100
|
**The firewall and webserver have to be stopped**.
|
59213008
Miguel Barão
- fixed user path...
|
101
|
|
43785de6
Miguel Barão
- added documenta...
|
102
103
104
|
```sh
sudo certbot certonly --standalone -d www.example.com # first time
sudo certbot renew # renew
|
59213008
Miguel Barão
- fixed user path...
|
105
|
```
|
93e13002
Miguel Barão
updates README.md.
|
106
107
108
|
Certificates are saved under
`/usr/local/etc/letsencrypt/live/www.example.com/`. Copy them to
|
bbc1c506
Miguel Barão
- documentation u...
|
109
|
`~/.local/share/certs` and change permissions to be readable:
|
43785de6
Miguel Barão
- added documenta...
|
110
|
|
443a1eea
Miguel Barão
Update to latest ...
|
111
|
```sh
|
5d859a41
Miguel Barão
update documentation
|
112
|
cd ~/.local/share/certs
|
43785de6
Miguel Barão
- added documenta...
|
113
|
sudo cp /usr/local/etc/letsencrypt/live/www.example.com/cert.pem .
|
bbc1c506
Miguel Barão
- documentation u...
|
114
|
sudo cp /usr/local/etc/letsencrypt/live/www.example.com/privkey.pem .
|
443a1eea
Miguel Barão
Update to latest ...
|
115
116
|
chmod 400 cert.pem privkey.pem
```
|
bbc1c506
Miguel Barão
- documentation u...
|
117
|
|
43785de6
Miguel Barão
- added documenta...
|
118
|
## Configuration
|
93e13002
Miguel Barão
updates README.md.
|
119
120
|
### Database
|
43785de6
Miguel Barão
- added documenta...
|
121
|
|
bbc1c506
Miguel Barão
- documentation u...
|
122
|
User data is maintained in a sqlite3 database which has to be created manually
|
443a1eea
Miguel Barão
Update to latest ...
|
123
124
125
|
using the `initdb-aprendizations` command. The database file should be located
in the same directory as the main YAML configuration file (`courses.yaml`).
|
bbc1c506
Miguel Barão
- documentation u...
|
126
|
For example, to run the included demo do:
|
43785de6
Miguel Barão
- added documenta...
|
127
|
|
443a1eea
Miguel Barão
Update to latest ...
|
128
|
```sh
|
43785de6
Miguel Barão
- added documenta...
|
129
130
131
132
|
cd demo # contains a small example
initdb-aprendizations # show or initialize database
initdb-aprendizations --admin # add admin user
initdb-aprendizations inscricoes.csv # add students from CSV
|
bbc1c506
Miguel Barão
- documentation u...
|
133
|
initdb-aprendizations --add 1184 "Aladino da Silva" # add new user
|
5d859a41
Miguel Barão
update documentation
|
134
135
136
137
|
initdb-aprendizations --update 1184 --pw alibaba # update password
initdb-aprendizations --help # for available options
```
|
443a1eea
Miguel Barão
Update to latest ...
|
138
139
|
The default password is equal to the user name, if left undefined.
|
39126690
Miguel Barão
removes npm and n...
|
140
|
### Running the demo
|
5d859a41
Miguel Barão
update documentation
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
The application includes a small example in `demo/courses.yaml` that can be
used for initial testing. Run it with
```sh
cd demo
aprendizations courses.yaml
```
Open the browser at [https://127.0.0.1:8443](https://127.0.0.1:8443).
If everything looks good, check at the correct address
`https://www.example.com:8443`.
The option `--debug` provides more verbose logging and might be useful during
testing.
|
93e13002
Miguel Barão
updates README.md.
|
156
|
### Firewall configuration
|
c55940af
Miguel Barão
- minor change in...
|
157
|
|
39126690
Miguel Barão
removes npm and n...
|
158
|
Ports 80 and 443 are only usable by root. For security reasons the server runs
|
443a1eea
Miguel Barão
Update to latest ...
|
159
|
as an unprivileged user on port 8443 for https. To access the server in the
|
f540e673
Miguel Barão
- added README.md
|
160
|
default https port (443), port forwarding must be configured in the firewall.
|
43785de6
Miguel Barão
- added documenta...
|
161
|
|
3ec49458
Miguel Barão
fix README.md and...
|
162
|
#### FreeBSD and pf
|
39126690
Miguel Barão
removes npm and n...
|
163
|
|
43785de6
Miguel Barão
- added documenta...
|
164
|
Edit `/etc/pf.conf`:
|
59213008
Miguel Barão
- fixed user path...
|
165
|
|
443a1eea
Miguel Barão
Update to latest ...
|
166
167
|
```sh
ext_if="em0" # change em0 to the correct network interface
|
93e13002
Miguel Barão
updates README.md.
|
168
|
rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
443a1eea
Miguel Barão
Update to latest ...
|
169
170
|
rdr on $ext_if proto tcp from any to any port 443 -> 127.0.0.1 port 8443
```
|
c288f8c6
Miguel Barao
- updated documen...
|
171
|
|
59213008
Miguel Barão
- fixed user path...
|
172
173
|
Virtualbox with guest additions uses `ext_if="vtnet0"`.
|
443a1eea
Miguel Barão
Update to latest ...
|
174
175
176
|
Edit `/etc/rc.conf`
```sh
|
59213008
Miguel Barão
- fixed user path...
|
177
178
179
180
181
|
pf_enable="YES"
pf_flags=""
pf_rules="/etc/pf.conf"
# optional logging:
|
43785de6
Miguel Barão
- added documenta...
|
182
|
pflog_enable="YES"
|
93e13002
Miguel Barão
updates README.md.
|
183
|
pflog_flags=""
|
43785de6
Miguel Barão
- added documenta...
|
184
185
186
|
pflog_logfile="/var/log/pflog"
```
|
59213008
Miguel Barão
- fixed user path...
|
187
|
Reboot or `sudo service pf start`.
|
5d859a41
Miguel Barão
update documentation
|
188
|
|
59213008
Miguel Barão
- fixed user path...
|
189
|
Example configuration files are in the `freebsd` directory.
|
43785de6
Miguel Barão
- added documenta...
|
190
|
|
59213008
Miguel Barão
- fixed user path...
|
191
|
### Testing the system
|
43785de6
Miguel Barão
- added documenta...
|
192
193
194
195
|
Make sure the following steps have been done:
* install python3 and pip
|
59213008
Miguel Barão
- fixed user path...
|
196
|
* install aprendizations using pip
|
43785de6
Miguel Barão
- added documenta...
|
197
198
199
200
201
|
* initialized database with at least 1 user
* generate and copy certificates to the appropriate place
* (optional) configure the firewall and port forwarding
* run `aprendizations courses.yaml`
|
59213008
Miguel Barão
- fixed user path...
|
202
|
## Keeping aprendizations updated
|
ea4ff4d2
Miguel Barão
- radio: added su...
|
203
|
|
59213008
Miguel Barão
- fixed user path...
|
204
|
To update aprendizations to the latest version do:
|
39126690
Miguel Barão
removes npm and n...
|
205
206
|
```sh
|
93e13002
Miguel Barão
updates README.md.
|
207
208
209
210
|
pip install -U git+https://git.xdi.uevora.pt/mjsb/aprendizations.git
```
## Troubleshooting
|
39126690
Miguel Barão
removes npm and n...
|
211
212
|
To help with troubleshooting, use the option `--debug` when running the server.
|
443a1eea
Miguel Barão
Update to latest ...
|
213
214
215
|
This will increase logs in the terminal and will present the python exception
errors in the browser.
|
39126690
Miguel Barão
removes npm and n...
|
216
|
Logging levels can be adjusted in `~/.config/aprendizations/logger.yaml` and
|
a203d3cc
Miguel Barão
- new http server...
|
217
|
`~/.config/aprendizations/logger-debug.yaml`.
|
5d859a41
Miguel Barão
update documentation
|
218
219
220
221
222
|
If these files do not yet exist, there are examples in `aprendizations/config`
that can be copied to `~/.config/aprendizations`.
### UnicodeEncodeError
|
39126690
Miguel Barão
removes npm and n...
|
223
|
|
5d859a41
Miguel Barão
update documentation
|
224
225
|
The server should not generate this error, but when using external scripts to
generate questions or to correct, these scripts can print unicode strings to
|
59213008
Miguel Barão
- fixed user path...
|
226
227
|
stdout. If the terminal does not support unicode, python will generate an
exception.
|
443a1eea
Miguel Barão
Update to latest ...
|
228
229
|
* FreeBSD fix: edit `~/.login_conf` to use UTF-8, for example:
|
5dae401a
Miguel Barão
update README.md
|
230
|
|
43785de6
Miguel Barão
- added documenta...
|
231
|
```sh
|
443a1eea
Miguel Barão
Update to latest ...
|
232
|
me:\
|
5dae401a
Miguel Barão
update README.md
|
233
|
:charset=UTF-8:\
|
43785de6
Miguel Barão
- added documenta...
|
234
|
:lang=en_US.UTF-8:
|
443a1eea
Miguel Barão
Update to latest ...
|
235
236
|
```
|
43785de6
Miguel Barão
- added documenta...
|
237
|
* Debian fix: check `locale`...
|
443a1eea
Miguel Barão
Update to latest ...
|
238
|
|
59213008
Miguel Barão
- fixed user path...
|
239
|
### The application runs but questions do not show up
|
443a1eea
Miguel Barão
Update to latest ...
|
240
241
242
|
Some operating systems have an option to disable animations to try to avoid
motion sickness in some people. Browsers will check this option with the OS and
|
5dae401a
Miguel Barão
update README.md
|
243
|
prevent animate.css library to work. Since questions have several animations,
|
59213008
Miguel Barão
- fixed user path...
|
244
|
these will will not work and nothing is shown on the page.
|
443a1eea
Miguel Barão
Update to latest ...
|
245
|
|
59213008
Miguel Barão
- fixed user path...
|
246
|
To fix this issue you need to allow animations in the Operating System:
|
43785de6
Miguel Barão
- added documenta...
|
247
248
249
250
251
|
* On windows 10, go to System Preferences, search for "Show animations in
windows" and turn it **ON**.
* On MacOS or iOS search for reduced motion and switch it **OFF**
(Preferences -> Acessibility -> Display -> Reduce motion).
|
f75a344f
Miguel Barão
- README.md updat...
|
252
|
|
443a1eea
Miguel Barão
Update to latest ...
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
## FAQ
Common database manipulations:
```sh
initdb-aprendizations -u 12345 --pw alibaba # reset student password
initdb-aprendizations -a 007 "James Bond" --pw mi6 # add new student "007"
```
Some common database queries:
```sh
# Which students did at least one topic?
sqlite3 students.db "select distinct student_id from studenttopic"
|
db04e658
Miguel Barão
- added option to...
|
268
|
# How many topics has each student done?
|
43785de6
Miguel Barão
- added documenta...
|
269
|
sqlite3 students.db "select student_id, count(topic_id) from studenttopic \
|
f75a344f
Miguel Barão
- README.md updat...
|
270
|
group by student_id order by count(topic_id) desc"
|
93e13002
Miguel Barão
updates README.md.
|
271
|
|
f75a344f
Miguel Barão
- README.md updat...
|
272
|
# Which questions have more wrong answers?
|
43785de6
Miguel Barão
- added documenta...
|
273
|
sqlite3 students.db "select count(ref), ref from answers where grade<1.0 \
|
d187aad4
Miguel Barão
- adds courses
|
274
275
|
group by ref order by count(ref) desc"
```
|
43785de6
Miguel Barão
- added documenta...
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
d187aad4
Miguel Barão
- adds courses
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|