Commit 1da435f293b01af9df0b88e19558ad5e75811e69
1 parent
c8de491d
Exists in
master
and in
1 other branch
Documentation updates and changed the python3.4 to python3 so that other versions can be used
Showing
7 changed files
with
56 additions
and
42 deletions
Show diff stats
README.md
| ... | ... | @@ -3,38 +3,52 @@ |
| 3 | 3 | |
| 4 | 4 | ### Requirements: |
| 5 | 5 | |
| 6 | -Installed using `pip3`: | |
| 6 | +The webserver is a python3 application and only requires python to be installed. Versions 3.3, 3.4 and 3.5 should be Ok. It does not require any other webserver (apache, ...) | |
| 7 | 7 | |
| 8 | -- CherryPy (3.7.0) | |
| 9 | -- Mako (1.0.1) | |
| 10 | -- Markdown (2.6.2) | |
| 11 | -- PyYAML (3.11) | |
| 12 | -- bcrypt (2.0.0) | |
| 8 | +Installed using `pip`: | |
| 9 | + | |
| 10 | +- CherryPy (>=3.7.0) | |
| 11 | +- Mako (>=1.0.1) | |
| 12 | +- Markdown (>=2.6.2) | |
| 13 | +- PyYAML (>=3.11) | |
| 14 | +- bcrypt (>=2.0.0) | |
| 13 | 15 | |
| 14 | 16 | ### System setup: |
| 15 | 17 | |
| 16 | -Open a terminal and navigate to a directory where this software is to be installed, e.g. `/var/www`. Then run the following commands: | |
| 18 | +Open a terminal and navigate to a directory where this software is to be installed, e.g. `/var/www` or `/home/username`. | |
| 19 | +Run the following commands: | |
| 17 | 20 | |
| 18 | -``` | |
| 19 | -#!bash | |
| 21 | +```.bash | |
| 22 | + | |
| 23 | +cd WHERE/TO/PUT/THE/SOFTWARE | |
| 20 | 24 | |
| 21 | -# get the software using git | |
| 25 | +# get software using git | |
| 22 | 26 | git clone https://mjsb@bitbucket.org/mjsb/perguntations.git |
| 23 | 27 | cd perguntations |
| 24 | 28 | |
| 25 | 29 | # create database in the directory db/ |
| 26 | -initdb_from_csv.py siiue.csv | |
| 30 | +./initdb_from_csv.py YOUR_CSV_FILE_HERE | |
| 27 | 31 | mkdir db |
| 28 | 32 | mv students.db db |
| 29 | 33 | |
| 30 | -# update test configuration | |
| 31 | -vi demo/test.yaml # update students_db | |
| 34 | +# update test configuration with the correct database file. | |
| 35 | +vi demo/test.yaml | |
| 36 | +# Edit line 7 to something like | |
| 37 | +# database: db/students.db | |
| 38 | + | |
| 39 | +# get help | |
| 40 | +./serve.py --help | |
| 32 | 41 | |
| 33 | 42 | # run demo test |
| 34 | -./serve demo/test.yaml | |
| 43 | +./serve.py demo/test.yaml | |
| 44 | + | |
| 45 | +# open browser at http://127.0.0.1:8080/ | |
| 46 | +# the professor is number 0 | |
| 47 | + | |
| 48 | +# ^C to terminate the server | |
| 35 | 49 | ``` |
| 36 | 50 | |
| 37 | -(For the time being, also create `ans`, `questions`, `tests`, `scripts`, `sessions` in the same directory, until paths are fixed) | |
| 51 | +(FIXME For the time being, also create `ans`, `questions`, `tests`, `scripts`, `sessions` in the same directory, until paths are fixed) | |
| 38 | 52 | |
| 39 | 53 | ### Contribute ### |
| 40 | 54 | ... | ... |
demo/correct-question.py
demo/generate-question.py
demo/questions.yaml
| 1 | 1 | - |
| 2 | 2 | ref: solar-system-jupiter |
| 3 | 3 | type: radio |
| 4 | - text: Which one is the largest planet? | |
| 4 | + text: Qual dos seguintes é o maior planeta? | |
| 5 | 5 | options: |
| 6 | 6 | - Jupiter |
| 7 | 7 | - Mercury |
| ... | ... | @@ -10,12 +10,12 @@ |
| 10 | 10 | correct: 0 |
| 11 | 11 | shuffle: True |
| 12 | 12 | discount: True |
| 13 | - hint: Just don't choose the wrong ones | |
| 13 | + hint: Também é o mais pesado. | |
| 14 | 14 | # --------------------------------------------------------------------------- |
| 15 | 15 | - |
| 16 | 16 | ref: solar-system-mars |
| 17 | 17 | type: checkbox |
| 18 | - text: Which ones are correct? | |
| 18 | + text: Quais das seguintes expressões são verdadeiras? | |
| 19 | 19 | options: |
| 20 | 20 | - $1 > 0$ |
| 21 | 21 | - $-1 > 1$ |
| ... | ... | @@ -24,28 +24,28 @@ |
| 24 | 24 | correct: [1, -1, 1, 0.5] |
| 25 | 25 | # optional |
| 26 | 26 | discount: True |
| 27 | - hint: There are three. | |
| 27 | + hint: Uma delas é falsa. | |
| 28 | 28 | # --------------------------------------------------------------------------- |
| 29 | 29 | - |
| 30 | 30 | ref: question-v1 |
| 31 | 31 | type: text |
| 32 | - text: What's your favorite basic color? | |
| 33 | - correct: ['blue', 'green'] | |
| 34 | - hint: It's not red. | |
| 32 | + text: Qual é a minha cor básica favorita? | |
| 33 | + correct: ['Azul', 'Verde'] | |
| 34 | + hint: Só há 3 cores básicas e não gosto de vermelho. | |
| 35 | 35 | # --------------------------------------------------------------------------- |
| 36 | 36 | - |
| 37 | 37 | ref: question-v2 |
| 38 | 38 | type: text_regex |
| 39 | - text: What's my favorite basic color? | |
| 40 | - correct: '[bB]lue' | |
| 41 | - hint: It's not red. | |
| 39 | + text: Qual é a minha cor básica favorita? | |
| 40 | + correct: '[aA]zul' | |
| 41 | + hint: O céu é... | |
| 42 | 42 | # --------------------------------------------------------------------------- |
| 43 | 43 | - |
| 44 | 44 | ref: question-colors |
| 45 | 45 | type: textarea |
| 46 | - text: Write names of the three basic colors. | |
| 46 | + text: Escreva o nome de três cores básicas. | |
| 47 | 47 | correct: correct-question.py |
| 48 | - hint: They start by RGB and order does not matter. | |
| 48 | + hint: Qualquer ordem serve. | |
| 49 | 49 | # --------------------------------------------------------------------------- |
| 50 | 50 | - |
| 51 | 51 | ref: question-whatever |
| ... | ... | @@ -58,14 +58,14 @@ |
| 58 | 58 | - |
| 59 | 59 | ref: one-question |
| 60 | 60 | type: information |
| 61 | - text: Please do not cheat. | |
| 61 | + text: Não vale fazer batota. | |
| 62 | 62 | # --------------------------------------------------------------------------- |
| 63 | 63 | - |
| 64 | 64 | ref: another-question |
| 65 | 65 | # type: information (default) |
| 66 | 66 | text: | |
| 67 | - The text of questions is parsed as __markdown__ and can include | |
| 68 | - LaTeX formulas $\sqrt{2\pi}$ and pretty code | |
| 67 | + O texto das perguntas é escrito em __markdown__ e pode incluir formulas em | |
| 68 | + LaTeX $\sqrt{2\pi}$ e código lindinho | |
| 69 | 69 | |
| 70 | 70 | ```.C |
| 71 | 71 | int main() { | ... | ... |
demo/test.yaml
| ... | ... | @@ -4,7 +4,7 @@ title: Teste de Demonstração |
| 4 | 4 | |
| 5 | 5 | # database contains students+passwords, final results of the tests, and questions done |
| 6 | 6 | # database: path/to/students.db |
| 7 | -database: inscritos.db | |
| 7 | +database: db/students.db | |
| 8 | 8 | |
| 9 | 9 | # this will generate a file for each test done. The file is like a replacement |
| 10 | 10 | # for a test done in paper. |
| ... | ... | @@ -17,8 +17,8 @@ practice: True |
| 17 | 17 | # debug: False |
| 18 | 18 | |
| 19 | 19 | #----------------------------------------------------------------------------- |
| 20 | -# This is the base path applied to the questions files and all the scripts | |
| 21 | -# including generators and correctors. | |
| 20 | +# Base path applied to the questions files and all the scripts | |
| 21 | +# including question generators and correctors. | |
| 22 | 22 | # Either absolute path or relative to current directory. |
| 23 | 23 | path: demo |
| 24 | 24 | # (Note: answers are saved in a different path defined in answers_dir) | ... | ... |
initdb_from_csv.py
serve.py
| 1 | -#!/usr/bin/env python3.4 | |
| 1 | +#!/usr/bin/env python3 | |
| 2 | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | |
| 4 | 4 | # The program runs a web server where students login to answer a sequence of questions. |
| ... | ... | @@ -10,14 +10,14 @@ import argparse |
| 10 | 10 | from os import path |
| 11 | 11 | |
| 12 | 12 | # path where this file is located |
| 13 | -server_path = path.dirname(path.realpath(__file__)) | |
| 13 | +SERVER_PATH = path.dirname(path.realpath(__file__)) | |
| 14 | +TEMPLATES_DIR = SERVER_PATH + '/templates' | |
| 14 | 15 | |
| 15 | 16 | # my code |
| 16 | 17 | from myauth import AuthController, require |
| 17 | 18 | import test |
| 18 | 19 | import database |
| 19 | 20 | |
| 20 | -TEMPLATES_DIR = server_path + '/templates' | |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | # ============================================================================ |
| ... | ... | @@ -153,7 +153,7 @@ class Root(object): |
| 153 | 153 | # ============================================================================ |
| 154 | 154 | def parse_arguments(): |
| 155 | 155 | argparser = argparse.ArgumentParser(description='Server for online tests. Enrolled students and tests have to be previously configured. Please read the documentation included with this software before running the server.') |
| 156 | - serverconf_file = path.normpath(path.join(server_path, 'config', 'server.conf')) | |
| 156 | + serverconf_file = path.normpath(path.join(SERVER_PATH, 'config', 'server.conf')) | |
| 157 | 157 | argparser.add_argument('--server', default=serverconf_file, type=str, help='server configuration file') |
| 158 | 158 | argparser.add_argument('--debug', action='store_true', |
| 159 | 159 | help='Show datastructures when rendering questions') |
| ... | ... | @@ -178,7 +178,7 @@ if __name__ == '__main__': |
| 178 | 178 | |
| 179 | 179 | print('=' * 79) |
| 180 | 180 | print('- Title: %s' % testconf['title']) |
| 181 | - print('- StudentsDB: %s' % testconf['database']) | |
| 181 | + print('- Database: %s' % testconf['database']) | |
| 182 | 182 | print('- Questions:\n ', '\n '.join(testconf['files'])) |
| 183 | 183 | print(' (%i questions read)' % len(testconf['questions'])) |
| 184 | 184 | print('-' * 79) |
| ... | ... | @@ -188,7 +188,7 @@ if __name__ == '__main__': |
| 188 | 188 | root = Root(testconf) |
| 189 | 189 | |
| 190 | 190 | # --- Mount and run server. |
| 191 | - cherrypy.config.update({'tools.staticdir.root': server_path}) | |
| 191 | + cherrypy.config.update({'tools.staticdir.root': SERVER_PATH}) | |
| 192 | 192 | cherrypy.quickstart(root, '/', config=arg.server) |
| 193 | 193 | cherrypy.log('Terminated OK ------------------------', 'APPLICATION') |
| 194 | 194 | print('\n- Server terminated OK') | ... | ... |