diff --git a/BUGS.md b/BUGS.md index 477889a..d6abc09 100644 --- a/BUGS.md +++ b/BUGS.md @@ -3,7 +3,6 @@ - click numa opcao checkbox fora da checkbox+label não está a funcionar. - shift-enter não está a funcionar -- nos topicos learn.yaml, qd falha acrescenta no fim. nao faz sentido. - mathjax, formulas $$f(x)$$ nas opções de escolha multipla, não ficam centradas em toda a coluna mas apenas na largura do parágrafo. - default prefix should be obtained from each course (yaml conf)? - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question. @@ -29,6 +28,8 @@ # FIXED +- nos topicos learn.yaml, qd falha acrescenta no fim. nao faz sentido. +- não esta a fazer render correcto de tabelas nas opcoes checkbox. e.g. information-theory/source-coding-theory/block-codes - max tries nas perguntas. - mostrar feedback/solucoes quando acerta, ou excede max tries. - quando se pressiona "responde" rapido (enquanto a animacao dura), a pergunta passa para a seguinte sem haver o correspondente redraw, ou seja a proxima resposta nao é a da pergunta mostrada. diff --git a/README.md b/README.md index 3f4f855..bf360c8 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ python3.7 -m ensurepip --user ``` This will install pip in your user account under `~/.local/bin`. -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`). +In the end you should be able to run `pip3 --version` and `python3 -c "import sqlite3"` without errors (sometimes `pip3` is `pip`, `pip3.7` or `pip-3.7`). If you want to always install python modules on the user account (recommended), edit the pip configuration file `~/.config/pip/pip.conf` (FreeBSD, Linux) or `Library/Application Support/pip/pip.conf` (MacOS) and add the lines @@ -93,7 +93,7 @@ cd aprendizations We need certificates for https. Certificates can be self-signed or validated by a trusted authority. -Self-signed can be used locally for development and testing, but browsers will complain. +Self-signed can be used locally for development and testing, but browsers will complain. LetsEncrypt issues trusted and free certificates, but the server must have a registered publicly accessible domain name. #### Selfsigned diff --git a/demo/demo.yaml b/demo/demo.yaml index 1d04519..2298e93 100644 --- a/demo/demo.yaml +++ b/demo/demo.yaml @@ -1,28 +1,25 @@ +--- + title: Example database: students.db -# path: ./demo + # values applie to each topic, if undefined there # default values are: file=question.yaml, shuffle=True, choose: all file: questions.yaml -shuffle: True +shuffle: false choose: 6 +max_tries: 2 forgetting_factor: 0.99 -# Representation of the edges of the dependency graph. -# Example: A depends on B and C -# A: -# name: Topic A -# deps: -# - B -# - C +# ---------------------------------------------------------------------------- topics: # topic without dependencies math: name: Matemática file: questions.yaml choose: 6 - shuffle: True + shuffle: true # topic with one dependency solar_system: diff --git a/demo/solar_system/questions.yaml b/demo/solar_system/questions.yaml index be37cf6..196d718 100644 --- a/demo/solar_system/questions.yaml +++ b/demo/solar_system/questions.yaml @@ -1,8 +1,41 @@ --- # --------------------------------------------------------------------------- -- ref: solar-system - type: radio +- type: checkbox + ref: teste-debug + title: tabelas em opcoes + text: ve la se as tabelas estao bem... + options: + - | + x | y + --|-- + 1 | 2 + - | + x | y + --|-- + 1 | 2 + correct: [1, 1] + +# --------------------------------------------------------------------------- +- type: radio + ref: teste-debug2 + title: formuolas em opcoes + text: ve la se as tabelas estao bem... + options: + - A + - B +# --------------------------------------------------------------------------- +- type: text + ref: home-planet + title: Sistema solar + text: O nosso planeta chama-se planeta... + correct: ['Terra', 'terra'] + # opcional + answer: Não é Marte... + +# --------------------------------------------------------------------------- +- type: radio + ref: solar-system title: Sistema solar text: | ![planetas](planets.png " Planetas do Sistema Solar") @@ -16,30 +49,20 @@ - Têm todos o mesmo tamanho # opcional correct: 2 - shuffle: False - discount: True + shuffle: false + discount: true -# --------------------------------------------------------------------------- -- - ref: home-planet - type: text - title: Sistema solar - text: O nosso planeta chama-se planeta... - correct: ['Terra', 'terra'] - # opcional - answer: Não é Marte... # --------------------------------------------------------------------------- -- - ref: saturn - type: text-regex - title: Sistema solar - text: O planeta do sistema solar conhecido por ter aneis é o planeta... - correct: !regex '[Ss]aturno' +- type: text-regex + ref: saturn + title: Sistema solar + text: O planeta do sistema solar conhecido por ter aneis é o planeta... + correct: !regex '[Ss]aturno' # --------------------------------------------------------------------------- -- ref: first_3_planets - type: textarea +- type: textarea + ref: first_3_planets title: Sistema solar text: Escreva o nome dos três planetas mais próximos do Sol. (Exemplo `A, B e C`) correct: correct-first_3_planets.py diff --git a/serve.py b/serve.py index c771707..2bd144f 100755 --- a/serve.py +++ b/serve.py @@ -23,7 +23,7 @@ from learnapp import LearnApp from tools import load_yaml, md_to_html # ---------------------------------------------------------------------------- -# Decorator used to restrict access to the administrator +# Decorator used to restrict access to the administrator only # ---------------------------------------------------------------------------- def admin_only(func): @functools.wraps(func) @@ -96,7 +96,7 @@ class LoginHandler(BaseHandler): login_ok = await self.learn.login(uid, pw) if login_ok: - self.set_secure_cookie('user', uid) # expires_days=30 + self.set_secure_cookie('user', uid) self.set_secure_cookie('counter', str(self.learn.get_login_counter(uid))) self.redirect('/') else: @@ -198,7 +198,6 @@ class FileHandler(BaseHandler): self.set_header("Content-Type", content_type) self.write(data) await self.flush() - # self.flush() # ---------------------------------------------------------------------------- @@ -216,8 +215,9 @@ class QuestionHandler(BaseHandler): 'textarea': 'question-textarea.html', # -- information panels -- 'information': 'question-information.html', - 'info': 'question-information.html', 'success': 'question-success.html', + 'warning': 'question-information.html', + 'alert': 'question-information.html', } # --- get question to render diff --git a/templates/question-checkbox.html b/templates/question-checkbox.html index 6940b9d..f3027eb 100644 --- a/templates/question-checkbox.html +++ b/templates/question-checkbox.html @@ -9,7 +9,7 @@
- +
{% end %} diff --git a/templates/question-radio.html b/templates/question-radio.html index 12c19f6..0df78bc 100644 --- a/templates/question-radio.html +++ b/templates/question-radio.html @@ -9,7 +9,7 @@
- +
{% end %} diff --git a/tools.py b/tools.py index abdec28..2f49a64 100644 --- a/tools.py +++ b/tools.py @@ -1,11 +1,11 @@ -# builtin +# python standard library from os import path import subprocess import logging import re -# packages +# user installed libraries import yaml import mistune from pygments import highlight @@ -117,8 +117,12 @@ class HighlightRenderer(mistune.Renderer): markdown = MarkdownWithMath(HighlightRenderer(escape=True)) # hard_wrap=True to insert
on newline -def md_to_html(text, q=None): - return markdown(text) +def md_to_html(text, strip_p_tag=False, q=None): + md = markdown(text) + if strip_p_tag and md.startswith('

') and md.endswith('

'): + return md[3:-5] + else: + return md # --------------------------------------------------------------------------- # load data from yaml file -- libgit2 0.21.2