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 ???` (not available yet?)
|
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/mjsb/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
|
We need certificates for https. Certificates can be self-signed or certificates validated by a trusted authority.
|
5dae401a
Miguel Barão
update README.md
|
75
76
|
Self-signed can be used for development, but browsers will complain.
LetsEncrypt issues trusted and free certificates, but the served must have a fixed IP and a domain name (not dynamic).
|
93e13002
Miguel Barão
updates README.md.
|
77
|
|
1e8f0810
Miguel Barão
update setup.py a...
|
78
|
#### Selfsigned
|
5dae401a
Miguel Barão
update README.md
|
79
80
|
Generate selfsigned certificates using
|
93e13002
Miguel Barão
updates README.md.
|
81
|
|
b4ceb7fc
Miguel Barão
minor change in l...
|
82
|
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
|
93e13002
Miguel Barão
updates README.md.
|
83
84
85
|
and place them in `aprendizations/certs`.
|
39126690
Miguel Barão
removes npm and n...
|
86
|
#### LetsEncrypt
|
93e13002
Miguel Barão
updates README.md.
|
87
|
|
f540e673
Miguel Barão
- added README.md
|
88
|
sudo pkg install py27-certbot # FreeBSD
|
59213008
Miguel Barão
- fixed user path...
|
89
90
|
Shutdown any server running and the firewall, and then run the script to generate the certificate:
|
443a1eea
Miguel Barão
Update to latest ...
|
91
92
|
sudo pfctl -d # disable pf firewall
|
c288f8c6
Miguel Barao
- updated documen...
|
93
|
sudo certbot certonly --standalone -d bit.xdi.uevora.pt
|
443a1eea
Miguel Barão
Update to latest ...
|
94
95
96
|
sudo pfctl -e; sudo pfctl -f /etc/pf.conf # enable pf firewall
Certificates are saved under `/usr/local/etc/letsencrypt/live/bit.xdi.uevora.pt/` which is readable only by root.
|
c288f8c6
Miguel Barao
- updated documen...
|
97
|
|
93e13002
Miguel Barão
updates README.md.
|
98
|
Copy them to `aprendizations/certs` with names `cert.pem` and `key.pem`. And change permissions to be readble (FIXME how to do it securily?)
|
f540e673
Miguel Barão
- added README.md
|
99
|
|
b4ceb7fc
Miguel Barão
minor change in l...
|
100
|
### Testing
|
59213008
Miguel Barão
- fixed user path...
|
101
|
|
43785de6
Miguel Barão
- added documenta...
|
102
103
104
|
Run a demonstration:
./serve.py demo/demo.yaml
|
59213008
Miguel Barão
- fixed user path...
|
105
|
|
93e13002
Miguel Barão
updates README.md.
|
106
107
108
|
and open a browser at `https://127.0.0.1:8443`.
Logging level can be adjusted in `config/logger.yaml`.
|
bbc1c506
Miguel Barão
- documentation u...
|
109
|
|
43785de6
Miguel Barão
- added documenta...
|
110
|
### Firewall configuration
|
443a1eea
Miguel Barão
Update to latest ...
|
111
|
|
5d859a41
Miguel Barão
update documentation
|
112
|
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.
|
43785de6
Miguel Barão
- added documenta...
|
113
|
|
bbc1c506
Miguel Barão
- documentation u...
|
114
|
#### FreeBSD and pf
|
443a1eea
Miguel Barão
Update to latest ...
|
115
116
|
Edit `/etc/pf.conf`:
|
bbc1c506
Miguel Barão
- documentation u...
|
117
|
|
43785de6
Miguel Barão
- added documenta...
|
118
|
ext_if="em0"
|
93e13002
Miguel Barão
updates README.md.
|
119
120
|
rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr on $ext_if proto tcp from any to any port 443 -> 127.0.0.1 port 8443
|
43785de6
Miguel Barão
- added documenta...
|
121
|
|
bbc1c506
Miguel Barão
- documentation u...
|
122
|
or `ext_if="vtnet0"` for guest additions under virtual box.
|
443a1eea
Miguel Barão
Update to latest ...
|
123
124
125
|
Edit `rc.conf`
|
bbc1c506
Miguel Barão
- documentation u...
|
126
|
pf_enable="YES"
|
43785de6
Miguel Barão
- added documenta...
|
127
|
pf_flags=""
|
443a1eea
Miguel Barão
Update to latest ...
|
128
|
pf_rules="/etc/pf.conf"
|
43785de6
Miguel Barão
- added documenta...
|
129
130
131
132
|
# optional logging:
pflog_enable="YES"
pflog_flags=""
|
bbc1c506
Miguel Barão
- documentation u...
|
133
|
pflog_logfile="/var/log/pflog"
|
5d859a41
Miguel Barão
update documentation
|
134
135
136
137
|
Reboot.
## Troubleshooting
|
443a1eea
Miguel Barão
Update to latest ...
|
138
139
|
#### UnicodeEncodeError
|
39126690
Miguel Barão
removes npm and n...
|
140
|
|
5d859a41
Miguel Barão
update documentation
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
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.
- FreeBSD fix: edit `~/.login_conf` to use UTF-8, for example:
me:\
:charset=UTF-8:\
:lang=en_US.UTF-8:
- Debian fix: check `locale`...
## Useful sqlite3 queries
Which students did at least one topic?
sqlite3 students.db "select distinct student_id from studenttopic"
|
93e13002
Miguel Barão
updates README.md.
|
156
|
|
c55940af
Miguel Barão
- minor change in...
|
157
|
|
39126690
Miguel Barão
removes npm and n...
|
158
|
How many topics had each student done?
|
443a1eea
Miguel Barão
Update to latest ...
|
159
|
|
f540e673
Miguel Barão
- added README.md
|
160
|
sqlite3 students.db "select student_id, count(topic_id) from studenttopic group by student_id order by count(topic_id) desc"
|
43785de6
Miguel Barão
- added documenta...
|
161
|
|
3ec49458
Miguel Barão
fix README.md and...
|
162
|
|
39126690
Miguel Barão
removes npm and n...
|
163
|
Which questions have more wrong answers?
|
43785de6
Miguel Barão
- added documenta...
|
164
|
|
59213008
Miguel Barão
- fixed user path...
|
165
|
sqlite3 students.db "select count(ref), ref from answers where grade<1.0 group by ref order by count(ref) desc"
|
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.
|
|
|