Compare commits

..

3 Commits

Author SHA1 Message Date
8e0121e8a8 Feat: graphiques et tableaux
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-15 09:30:32 +02:00
de353a3d26 Feat: add tkzfonct file 2020-08-15 09:30:07 +02:00
ffadbd7ce6 Feat: skeleton to create new sequence 2020-08-14 15:06:30 +02:00
8 changed files with 325 additions and 49 deletions

2
.gitignore vendored
View File

@ -13,6 +13,7 @@
**/*.tdo
**/*.amc
**/*.xsim
**/*.tkzfonct.*
**/tmp/*
@ -25,3 +26,4 @@ test/
.venv/
venv/
video/

118
tasks.py Normal file
View File

@ -0,0 +1,118 @@
from invoke import task
from pathlib import Path
from prompt_toolkit import prompt
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.validation import Validator
from unidecode import unidecode
import jinja2
from pytex import texenv
import datetime
import locale
locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8")
TRIBES = [
{"name": "Première Technologique", "directory": "1ST"},
{"name": "Science numérique et technologique", "directory": "SNT"},
{"name": "Terminale L-ES", "directory": "TESL"},
{"name": "Terminale sti2d", "directory": "Tsti2d"},
]
AUTHOR = "Benjamin Bertrand"
def is_tribe(tribe):
return tribe in [t["directory"] for t in TRIBES]
def get_sequences(tribe):
p = Path(tribe)
return [x for x in p.iterdir() if (x.is_dir() and x.name[0:2].isdigit())]
def get_tags(tribe=""):
p = Path(tribe)
tags = set()
indexes = p.glob("**/index.rst")
for index_p in indexes:
with open(index_p, "r") as index:
line = index.readline()
while line:
if line.startswith(":tags"):
tags.update(line[7:].replace("\n", "").split(', '))
break
line = index.readline()
return {t.lower() for t in tags}
def next_weekday(date, day=0):
return date + datetime.timedelta(days=(day-date.weekday()+7)%7)
def sequence_prompt():
sequence = {}
print("Nouvelle séquence")
sequence["author"] = prompt("Auteur: ", default=AUTHOR)
sequence["date"] = datetime.date.today()
tribes = WordCompleter([t["directory"] for t in TRIBES])
sequence["tribe"] = prompt("Classe: ", completer=tribes, validator=Validator.from_callable(is_tribe))
sequences = get_sequences(sequence["tribe"])
print("Séquences trouvées:\n\t" + '\n\t'.join(sorted([s.name for s in sequences])))
sequence["num"] = len(sequences) + 1
sequence["title"] = prompt(f"Nom de la séquence (n°{sequence['num']}): ")
known_tags = get_tags()
sequence["tags"] = prompt("Tags (séparés par une virgule): ", completer=WordCompleter(known_tags))
sequence["summary"] = prompt("Résumé: ")
return sequence
def import_skel(dest, datas, skel="sequence", skel_path="./tools/skeleton"):
d = Path(dest)
d.mkdir()
p = Path(skel_path + "/" + skel)
files = [t.name for t in p.iterdir()]
template_loader = jinja2.FileSystemLoader(searchpath=p)
template_env = jinja2.Environment(loader=template_loader)
texenv.loader.loaders.append(template_loader)
print("")
for filename in files:
if filename.endswith(".tex"):
template = texenv.get_template(filename)
else:
template = template_env.get_template(filename)
output_text = template.render(**datas)
with open(d/filename, "w") as f:
f.write(output_text)
print(f"Importation de {filename} - OK")
@task
def sequence(c):
sequence = sequence_prompt()
dest = unidecode(("{tribe}/{num:0>2}_{title}/".format(**sequence)).replace(" ", "_"))
dest = Path(dest)
seq_summary = """\
Séquence: {num:0>2} {title}
Niveau: {tribe}
Auteur: {author}
Date: {date}
Tags: {tags}
Sommaire: {summary}
Dossier: {dest}
""".format(dest=dest, **sequence)
print(seq_summary)
validate = prompt("C'est ok? ")
if validate.lower() in ["o", "y", ""]:
sequence["title_under"] = '#'*len(sequence["title"])
import_skel(dest, sequence, "sequence")
else:
print("Tant pis. Ya plus qu'à recommencer.")

View File

@ -32,7 +32,7 @@
\item \verb+\vectCoord+ $\vectCoord{\#1}{\#2}$
\item \verb+\e+ $\e$
% \item \verb+\i+ $\i$
% \item \verb+\i+ $\i$
\item \verb+\coefBino+ $\coefBino{\#1}{\#2}$
@ -57,39 +57,39 @@
\item \verb+\SignalBar+ \SignalBar{2}
\item \verb+\Assesment+ \Assesment{3}
\item \verb+\competencesStatement+ \competencesStatement
\end{itemize}
\end{itemize}
\section{tikzpicture}
\begin{verbatim}
\begin{verbatim}
\begin{tikzpicture}[scale=1]
...
\end{tikzpicture}
\end{verbatim}
\begin{itemize}
\item \verb+\cercleTrigo+
\begin{tikzpicture}[scale=1]
\cercleTrigo
\end{tikzpicture}
\item \verb+\cercleTrigoNoOIJ+
\begin{tikzpicture}[scale=1]
\cercleTrigoNoOIJ
\end{tikzpicture}
\item \verb+\repere+
\begin{tikzpicture}[scale=1]
\repere{-2}{2}{-2}{2}
\end{tikzpicture}
\item \verb+\repereNoGrid+
\begin{tikzpicture}[scale=1]
\repereNoGrid{-2}{2}{-2}{2}
\end{tikzpicture}
\item \verb+\boxplot+
\begin{tikzpicture}[scale=1]
\boxplot{2}{0}{1}{2}{3}{4}{5}
\end{tikzpicture}
\item \verb+\boxplotNoNames+
\begin{tikzpicture}[scale=1]
\boxplotNoNames{2}{0}{1}{2}{3}{4}{5}
\end{tikzpicture}
\end{verbatim}
\begin{itemize}
\item \verb+\cercleTrigo+
\begin{tikzpicture}[scale=1]
\cercleTrigo
\end{tikzpicture}
\item \verb+\cercleTrigoNoOIJ+
\begin{tikzpicture}[scale=1]
\cercleTrigoNoOIJ
\end{tikzpicture}
\item \verb+\repere+
\begin{tikzpicture}[scale=1]
\repere{-2}{2}{-2}{2}
\end{tikzpicture}
\item \verb+\repereNoGrid+
\begin{tikzpicture}[scale=1]
\repereNoGrid{-2}{2}{-2}{2}
\end{tikzpicture}
\item \verb+\boxplot+
\begin{tikzpicture}[scale=1]
\boxplot{2}{0}{1}{2}{3}{4}{5}
\end{tikzpicture}
\item \verb+\boxplotNoNames+
\begin{tikzpicture}[scale=1]
\boxplotNoNames{2}{0}{1}{2}{3}{4}{5}
\end{tikzpicture}
\end{itemize}
\section{Mise en avant}
@ -105,20 +105,9 @@
\end{itemize}
\section{Algo}
\begin{verbatim}
\begin{algorithm}[H]
\SetAlgoLined
\Entree{n}
\Deb{
$u \leftarrow 3$ \;
\Pour{$i$ de 1 à 3}{
$u \leftarrow u+2$ \;
}
}
\Sortie{u}
\end{algorithm}
\end{verbatim}
\begin{multicols}{2}
\begin{verbatim}
\begin{algorithm}[H]
\SetAlgoLined
\Entree{n}
@ -130,24 +119,44 @@
}
\Sortie{u}
\end{algorithm}
\end{verbatim}
\columnbreak
\begin{algorithm}[H]
\SetAlgoLined
\Entree{n}
\Deb{
$u \leftarrow 3$ \;
\Pour{$i$ de 1 à 3}{
$u \leftarrow u+2$ \;
}
}
\Sortie{u}
\end{algorithm}
\end{multicols}
\section{Programmation}
\begin{verbatim}
\begin{lstlisting}[language=Python, basicstyle=\small, frame=]
\begin{multicols}{2}
\begin{verbatim}
\begin{lstlisting}[language=Python, basicstyle=\small, frame=]
x = ("Nombre de tirage?")
if x < 200:
print("Le tarif est ", x*0.11)
else:
print("Le tarif est ", x*0.8)
\end{lstlisting}
\end{verbatim}
\begin{lstlisting}[language=Python, basicstyle=\small, frame=]
\end{lstlisting}
\end{verbatim}
\columnbreak
\begin{lstlisting}[language=Python, basicstyle=\small, frame=]
x = ("Nombre de tirage?")
if x < 200:
print("Le tarif est ", x*0.11)
else:
print("Le tarif est ", x*0.8)
\end{lstlisting}
\end{lstlisting}
\end{multicols}
\section{QRcode}
@ -155,5 +164,98 @@
\qrcode{phrase à coder}
\section{Graphique et tableaux}
\subsection{Grahique}
\begin{multicols}{2}
\begin{verbatim}
\begin{tikzpicture}[baseline=(a.north),
xscale=1, yscale=0.5]
\tkzInit[xmin=-5,xmax=5,xstep=1,
ymin=-5,ymax=5,ystep=1]
\tkzGrid
\tkzAxeXY
\tkzFct[domain=-5:5,color=red,very thick]%
{ 0.4*x*x - 3 };
\end{tikzpicture}
\end{verbatim}
\columnbreak
\begin{tikzpicture}[baseline=(a.north),
xscale=1, yscale=0.5]
\tkzInit[xmin=-5,xmax=5,xstep=1,
ymin=-5,ymax=5,ystep=1]
\tkzGrid
\tkzAxeXY
\tkzFct[domain=-5:5,color=red,very thick]%
{ 0.4*x*x - 3 };
\end{tikzpicture}
\end{multicols}
Quand on change la valeur de \verb+xstep+, il faut replacer \verb+x+ par \verb+\x+.
\begin{multicols}{2}
\begin{verbatim}
\begin{tikzpicture}[baseline=(a.north),
xscale=0.5, yscale=0.4]
\tkzInit[xmin=-5,xmax=5,xstep=0.5,
ymin=-5,ymax=5,ystep=1]
\tkzGrid
\tkzAxeXY
\tkzFct[domain=-5:5,color=red,very thick]%
{ 0.4*\x*\x - 3 };
\end{tikzpicture}
\end{verbatim}
\columnbreak
\begin{tikzpicture}[baseline=(a.north),
xscale=0.5, yscale=0.4]
\tkzInit[xmin=-5,xmax=5,xstep=0.5,
ymin=-5,ymax=5,ystep=1]
\tkzGrid
\tkzAxeXY
\tkzFct[domain=-5:5,color=red,very thick]%
{ 0.4*\x*\x - 3 };
\end{tikzpicture}
\end{multicols}
\subsection{Tableau de signes et variations}
\begin{multicols}{2}
\begin{verbatim}
\begin{tikzpicture}[baseline=(a.north)]
\tkzTabInit[lgt=2,espcl=2]
{$ x $/1,$ f(x) $/2}{-1, 2, 3, 5}
\tkzTabLine{, +, z, +, z, -, d, + , }
\end{tikzpicture}
\end{verbatim}
\columnbreak
\begin{tikzpicture}[baseline=(a.north)]
\tkzTabInit[lgt=2,espcl=2]
{$ x $/1,$ f(x) $/2}{-1, 2, 3, 5}
\tkzTabLine{, +, z, +, z, -, d, + , }
\end{tikzpicture}
\end{multicols}
\begin{multicols}{2}
\begin{verbatim}
\begin{tikzpicture}[baseline=(a.north)]
\tkzTabInit[lgt=2,espcl=2]
{$ x $/1, $ f(x) $/2}{-2, 0, 1 }
\tkzTabVar{ +/3, -/1, +/5}
\end{tikzpicture}
\end{verbatim}
\columnbreak
\begin{tikzpicture}[baseline=(a.north)]
\tkzTabInit[lgt=2,espcl=2]
{$ x $/1, $ f(x) $/2}{-2, 0, 1 }
\tkzTabVar{ +/3, -/1, +/5}
\end{tikzpicture}
\end{multicols}
\end{document}

14
tools/skeleton/sequence/B1.tex Executable file
View File

@ -0,0 +1,14 @@
\documentclass[a4paper,10pt]{article}
\usepackage{myXsim}
\author{\Var{ author }}
\title{\Var{title} - Cours}
\date{\Var{date.strftime("%B %Y")}
\pagestyle{empty}
\begin{document}
\maketitle
\end{document}

18
tools/skeleton/sequence/E1.tex Executable file
View File

@ -0,0 +1,18 @@
\documentclass[a4paper,10pt]{article}
\usepackage{myXsym}
\author{\Var{ author }}
\title{\Var{title} - Cours}
\date{\Var{date.strftime("%B %Y")}
\DeclareExerciseCollection{banque}
\xsimsetup{
step=1,
}
\begin{document}
\input{exercises.tex}
\printcollection{banque}
\end{document}

View File

@ -0,0 +1,10 @@
\collectexercises{banque}
\begin{exercise}[subtitle={<++>}, step={1}, origin={<++>}, topics={\Var{title}}, tags={\Var{tags}}]
<++>
\end{exercise}
\begin{solution}
<++>
\end{solution}
\collectexercisesstop{banque}

View File

@ -0,0 +1,12 @@
{{ title }}
{{ title_under }}
:date: 2020-08-14
:modified: 2020-08-14
:authors: {{ author }}
:tags: {{ tags }}
:category: {{ tribe }}
:summary: {{ summary }}
Étape 1:
========