43785de6
Miguel Barão
- added documenta...
|
1
|
# Get Started
|
a96cd2c7
Miguel Barão
- added logging s...
|
2
|
|
1e8f0810
Miguel Barão
update setup.py a...
|
3
|
|
5d859a41
Miguel Barão
update documentation
|
4
5
6
|
## Requirements
We will need to install python3.6 with sqlite3 support.
|
93e13002
Miguel Barão
updates README.md.
|
7
|
This can be done using the system package management, downloaded from [http://www.python.org](), or compiled from sources.
|
a96cd2c7
Miguel Barão
- added logging s...
|
8
|
|
39126690
Miguel Barão
removes npm and n...
|
9
10
11
12
|
- Installing from the system package management:
- OSX: `port install python36`
- FreeBSD: `pkg install python36 py36-sqlite3`
- Linux: `apt-get install ???`
|
f540e673
Miguel Barão
- added README.md
|
13
|
- Installing from sources:
|
5d859a41
Miguel Barão
update documentation
|
14
15
|
- Download from [http://www.python.org]()
- `unxz Python-3.6.tar.xz`
|
39126690
Miguel Barão
removes npm and n...
|
16
|
- `tar xvf Python-3.6.tar`
|
443a1eea
Miguel Barão
Update to latest ...
|
17
|
- `cd Python-3.6`
|
39126690
Miguel Barão
removes npm and n...
|
18
|
- `./configure --prefix=$HOME/.local/bin`
|
5d859a41
Miguel Barão
update documentation
|
19
20
|
- `make && make install`
|
43785de6
Miguel Barão
- added documenta...
|
21
|
This will install python locally under `~/.local/bin`. Make sure to add it to your `PATH` (edit `~/.profile` in OSX or FreeBSD).
|
39126690
Miguel Barão
removes npm and n...
|
22
|
|
43785de6
Miguel Barão
- added documenta...
|
23
|
Next install pip (if not yet installed):
|
39126690
Miguel Barão
removes npm and n...
|
24
25
|
python3.6 -m ensurepip --user
|
c54ee176
Miguel Barão
update javascript...
|
26
27
|
This will install pip in your account under `~/.local/bin`.
|
39126690
Miguel Barão
removes npm and n...
|
28
29
|
In the end you should be able to run `pip3 --version` and `python3 -c "import sqlite3"` without errors (sometimes `pip3` is `pip`, `pip3.6` or `pip-3.6`).
|
1e8f0810
Miguel Barão
update setup.py a...
|
30
|
Install additional python packages locally on the user area:
|
93e13002
Miguel Barão
updates README.md.
|
31
32
|
pip3 install --user \
|
43785de6
Miguel Barão
- added documenta...
|
33
|
tornado \
|
59213008
Miguel Barão
- fixed user path...
|
34
|
sqlalchemy \
|
443a1eea
Miguel Barão
Update to latest ...
|
35
|
pyyaml \
|
a96cd2c7
Miguel Barão
- added logging s...
|
36
|
pygments \
|
43785de6
Miguel Barão
- added documenta...
|
37
|
markdown \
|
39126690
Miguel Barão
removes npm and n...
|
38
39
|
bcrypt \
networkx
|
1e8f0810
Miguel Barão
update setup.py a...
|
40
|
|
43785de6
Miguel Barão
- added documenta...
|
41
|
These are usually installed under
|
f540e673
Miguel Barão
- added README.md
|
42
|
|
443a1eea
Miguel Barão
Update to latest ...
|
43
44
|
- OSX: `~/Library/python/3.6/lib/python/site-packages/`
- Linux/FreeBSD: `~/.local/lib/python3.6/site-packages/`
|
39126690
Miguel Barão
removes npm and n...
|
45
|
|
5d859a41
Miguel Barão
update documentation
|
46
|
Note: If you want to always install python modules on the user account, edit the pip configuration file `~/.config/pip/pip.conf` (FreeBSD, Linux) or `Library/Application Support/pip/pip.conf` (OSX) and add the lines
|
1e8f0810
Miguel Barão
update setup.py a...
|
47
48
49
50
51
|
[global]
user = yes
## Installation
|
5dae401a
Miguel Barão
update README.md
|
52
|
|
f540e673
Miguel Barão
- added README.md
|
53
|
Replace USER by your bitbucket username:
|
43785de6
Miguel Barão
- added documenta...
|
54
55
56
57
|
cd path/to/some/directory
git clone https://USER@bitbucket.org/USER/aprendizations.git
|
f540e673
Miguel Barão
- added README.md
|
58
|
A directory `aprendizations` will be created with the software:
|
39126690
Miguel Barão
removes npm and n...
|
59
|
|
f540e673
Miguel Barão
- added README.md
|
60
|
cd aprendizations
|
43785de6
Miguel Barão
- added documenta...
|
61
|
|
39126690
Miguel Barão
removes npm and n...
|
62
|
## Configuration
|
43785de6
Miguel Barão
- added documenta...
|
63
|
|
f540e673
Miguel Barão
- added README.md
|
64
|
### Database
|
c3eba869
Miguel Barão
update README.md
|
65
|
|
a96cd2c7
Miguel Barão
- added logging s...
|
66
|
First we need to create a database:
|
443a1eea
Miguel Barão
Update to latest ...
|
67
|
|
1e8f0810
Miguel Barão
update setup.py a...
|
68
|
./initdb.py # initialize user `0` and empty password
|
a96cd2c7
Miguel Barão
- added logging s...
|
69
|
./initdb.py --pw alibaba # initialize user `0` and given password
|
443a1eea
Miguel Barão
Update to latest ...
|
70
|
./initdb.py --help # for the available options
|
39126690
Miguel Barão
removes npm and n...
|
71
|
|
f540e673
Miguel Barão
- added README.md
|
72
|
### SSL Certificates
|
39126690
Miguel Barão
removes npm and n...
|
73
74
|
#### Selfsigned
|
5dae401a
Miguel Barão
update README.md
|
75
76
|
We also need certificates for https. Generate selfsigned certificates using openssl:
|
93e13002
Miguel Barão
updates README.md.
|
77
|
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
|
1e8f0810
Miguel Barão
update setup.py a...
|
78
|
|
5dae401a
Miguel Barão
update README.md
|
79
80
|
and place them in `aprendizations/certs`.
|
93e13002
Miguel Barão
updates README.md.
|
81
|
#### LetsEcrypt
|
b4ceb7fc
Miguel Barão
minor change in l...
|
82
|
|
93e13002
Miguel Barão
updates README.md.
|
83
84
85
|
sudo pkg install py27-certbot # FreeBSD
Shutdown any server running and the firewall, and then run the script to generate the certificate:
|
39126690
Miguel Barão
removes npm and n...
|
86
|
|
93e13002
Miguel Barão
updates README.md.
|
87
|
sudo pfctl -d # disable pf firewall
|
f540e673
Miguel Barão
- added README.md
|
88
|
sudo certbot certonly --standalone -d bit.xdi.uevora.pt
|
59213008
Miguel Barão
- fixed user path...
|
89
90
|
sudo pfctl -e; sudo pfctl -f /etc/pf.conf # enable pf firewall
|
443a1eea
Miguel Barão
Update to latest ...
|
91
92
|
Certificates are saved under `/usr/local/etc/letsencrypt/live/bit.xdi.uevora.pt/` which is readable only by root.
|
c288f8c6
Miguel Barao
- updated documen...
|
93
|
Copy them to `aprendizations/certs` with names `cert.pem` and `key.pem`. And change permissions to be readble (FIXME how to do it with security?)
|
443a1eea
Miguel Barão
Update to latest ...
|
94
95
96
|
### Testing
|
c288f8c6
Miguel Barao
- updated documen...
|
97
|
|
93e13002
Miguel Barão
updates README.md.
|
98
|
Run a demonstration:
|
f540e673
Miguel Barão
- added README.md
|
99
|
|
b4ceb7fc
Miguel Barão
minor change in l...
|
100
|
./serve.py demo/demo.yaml
|
59213008
Miguel Barão
- fixed user path...
|
101
|
|
43785de6
Miguel Barão
- added documenta...
|
102
103
104
|
and open a browser at `https://127.0.0.1:8443`.
### Firewall configuration
|
59213008
Miguel Barão
- fixed user path...
|
105
|
|
93e13002
Miguel Barão
updates README.md.
|
106
107
108
|
Ports 80 and 443 are only usable by root. For security reasons it is better to run the server as a regular user on higher ports like 8080 for http and 8443 for https. In this case, we should configure port forwarding in the firewall to redirect incoming tcp traffic from 80 to 8080 and 443 to 8443.
#### FreeBSD and pf
|
bbc1c506
Miguel Barão
- documentation u...
|
109
|
|
43785de6
Miguel Barão
- added documenta...
|
110
|
Edit `/etc/pf.conf`:
|
443a1eea
Miguel Barão
Update to latest ...
|
111
|
|
5d859a41
Miguel Barão
update documentation
|
112
|
ext_if="em0"
|
43785de6
Miguel Barão
- added documenta...
|
113
|
rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
|
bbc1c506
Miguel Barão
- documentation u...
|
114
|
rdr on $ext_if proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
443a1eea
Miguel Barão
Update to latest ...
|
115
116
|
or `ext_if="vtnet0"` for guest additions under virtual box.
|
bbc1c506
Miguel Barão
- documentation u...
|
117
|
|
43785de6
Miguel Barão
- added documenta...
|
118
|
Edit `rc.conf`
|
93e13002
Miguel Barão
updates README.md.
|
119
120
|
pf_enable="YES"
|
43785de6
Miguel Barão
- added documenta...
|
121
|
pf_flags=""
|
bbc1c506
Miguel Barão
- documentation u...
|
122
|
pf_rules="/etc/pf.conf"
|
443a1eea
Miguel Barão
Update to latest ...
|
123
124
125
|
# optional logging:
pflog_enable="YES"
|
bbc1c506
Miguel Barão
- documentation u...
|
126
|
pflog_flags=""
|
43785de6
Miguel Barão
- added documenta...
|
127
|
pflog_logfile="/var/log/pflog"
|
443a1eea
Miguel Barão
Update to latest ...
|
128
|
|
43785de6
Miguel Barão
- added documenta...
|
129
130
131
132
|
Reboot.
## Troubleshooting
|
bbc1c506
Miguel Barão
- documentation u...
|
133
|
#### UnicodeEncodeError
|
5d859a41
Miguel Barão
update documentation
|
134
135
136
137
|
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 stdout. If the terminal does not support unicode, python will generate this exception.
To correct in FreeBSD, edit `~/.login_conf` to use UTF-8, for example:
|
443a1eea
Miguel Barão
Update to latest ...
|
138
139
|
me:\
|
39126690
Miguel Barão
removes npm and n...
|
140
|
:charset=UTF-8:\
|
5d859a41
Miguel Barão
update documentation
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
:lang=en_US.UTF-8:
## Useful sqlite3 queries
Which students have already done at least one topic?
sqlite3 students.db "select distinct student_id from studenttopic"
How many topics have done each student?
sqlite3 students.db "select student_id, count(topic_id) from studenttopic group by student_id"
What questions have more wrong answers?
|
93e13002
Miguel Barão
updates README.md.
|
156
|
|
c55940af
Miguel Barão
- minor change in...
|
157
|
sqlite3 students.db "select count(ref), ref from answers where grade<1.0 group by ref order by count(ref) desc"
|
39126690
Miguel Barão
removes npm and n...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
f540e673
Miguel Barão
- added README.md
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
3ec49458
Miguel Barão
fix README.md and...
|
|
|
39126690
Miguel Barão
removes npm and n...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
c288f8c6
Miguel Barao
- updated documen...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
5d859a41
Miguel Barão
update documentation
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
ea4ff4d2
Miguel Barão
- radio: added su...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
39126690
Miguel Barão
removes npm and n...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
39126690
Miguel Barão
removes npm and n...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
39126690
Miguel Barão
removes npm and n...
|
|
|
a203d3cc
Miguel Barão
- new http server...
|
|
|
5d859a41
Miguel Barão
update documentation
|
|
|
39126690
Miguel Barão
removes npm and n...
|
|
|
5d859a41
Miguel Barão
update documentation
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
5dae401a
Miguel Barão
update README.md
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
5dae401a
Miguel Barão
update README.md
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
5dae401a
Miguel Barão
update README.md
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
59213008
Miguel Barão
- fixed user path...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
443a1eea
Miguel Barão
Update to latest ...
|
|
|
db04e658
Miguel Barão
- added option to...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
93e13002
Miguel Barão
updates README.md.
|
|
|
f75a344f
Miguel Barão
- README.md updat...
|
|
|
43785de6
Miguel Barão
- added documenta...
|
|
|
d187aad4
Miguel Barão
- adds courses
|
|
|
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.
|
|
|