Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle to amc
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathieu Loiseau
moodle to amc
Commits
8ce9214b
Commit
8ce9214b
authored
3 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
génération exam
parent
a6356fc9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+22
-0
22 additions, 0 deletions
README.md
XML_Moodle.py
+32
-6
32 additions, 6 deletions
XML_Moodle.py
model.tex
+29
-0
29 additions, 0 deletions
model.tex
with
83 additions
and
6 deletions
README.md
+
22
−
0
View file @
8ce9214b
...
@@ -27,3 +27,25 @@ Ce module marche pour MA feuille de style AMC, qui contient :
...
@@ -27,3 +27,25 @@ Ce module marche pour MA feuille de style AMC, qui contient :
et où
``{mlang en}``
et
``{mlang other}``
sont utilisés dans moodle.
et où
``{mlang en}``
et
``{mlang other}``
sont utilisés dans moodle.
Mettre
``unsafe``
à
``False``
pour ne pas remplacer les
``<span>``
(
`utils.py`
)
Mettre
``unsafe``
à
``False``
pour ne pas remplacer les
``<span>``
(
`utils.py`
)
On peut fournir un un modèle LaTeX de sujet contenant
```%%%Exam content%%%```
à l'endroit où mettre le contenu de l'exam
```
bash
usage: mood2amc.py
[
-h
]
[
-m
MOODLEDB]
[
-u
]
[
-d
DESTINATION]
[
-s
SUB_DIR]
Convertir un
export
de base de questions moodle en sujet AMC
ex :
‣./mood2amc.py
-m
base-de-questions_moodle.xml
‣./mood2amc.py
-u
-m
data/base-de-questions_moodle.xml
-d
data
-s
images
‣./mood2amc.py
-m
bdm.xml
-d
/home/user/Documents/Exams/mon_super_exam
optional arguments:
-h
,
--help
show this
help
message and
exit
-m
MOODLEDB,
--moodledb
MOODLEDB
la base de questions moodle xml à convertir
-u
,
--unsafe
convertir les <span> monospace en listings
(
dangereux
)
-d
DESTINATION,
--destination
DESTINATION
dossier de destination
-s
SUB_DIR,
--sub_dir
SUB_DIR
Dossier où mettre les images et listings
(
sous-dossier de destination
)
```
This diff is collapsed.
Click to expand it.
XML_Moodle.py
+
32
−
6
View file @
8ce9214b
...
@@ -3,6 +3,7 @@ import xml.etree.ElementTree as ET
...
@@ -3,6 +3,7 @@ import xml.etree.ElementTree as ET
from
unidecode
import
unidecode
from
unidecode
import
unidecode
from
utils
import
strip_tags
,
mlang_2_multiling
,
score_2_str
from
utils
import
strip_tags
,
mlang_2_multiling
,
score_2_str
import
base64
import
base64
from
sys
import
path
from
PIL
import
Image
from
PIL
import
Image
from
io
import
BytesIO
from
io
import
BytesIO
from
re
import
findall
,
DOTALL
from
re
import
findall
,
DOTALL
...
@@ -52,21 +53,46 @@ class Quizz:
...
@@ -52,21 +53,46 @@ class Quizz:
def
__str__
(
self
):
def
__str__
(
self
):
res
=
""
res
=
""
digest
=
"
%%%Exemple d
'
examen
\n\t\t
%
\\
cleargroup{exam}
\n
"
count
=
0
for
c
,
c_q
in
self
.
questions
.
items
():
for
c
,
c_q
in
self
.
questions
.
items
():
tmp
=
"
\t\t
%
\\
shufflegroup{
"
+
self
.
categories
[
c
]
+
"
}%(
"
+
c
+
"
):
"
count
=
0
for
q
in
c_q
:
for
q
in
c_q
:
res
+=
str
(
q
)
res
+=
str
(
q
)
count
+=
1
count
+=
1
print
(
count
,
"
questions processed.
"
)
return
res
def
get_exam
(
self
,
output_path
,
model
=
None
):
digest
=
"
%%%Exemple d
'
examen
\n\t\t\\
cleargroup{exam}
\n
"
totalq
=
0
totalpoints
=
0
for
c
,
c_q
in
self
.
questions
.
items
():
tmp
=
"
\t\t\\
shufflegroup{
"
+
self
.
categories
[
c
]
+
"
}%(
"
+
c
+
"
):
"
count
=
0
score
=
0
for
q
in
c_q
:
count
+=
1
score
+=
q
.
max
totalq
+=
1
totalpoints
+=
q
.
max
if
count
>
0
:
if
count
>
0
:
digest
+=
f
"
{
tmp
}{
count
}
questions
\n\t\t
%
\\
copygroup[
{
int
(
count
/
2
)
}
]
"
+
"
{
"
+
self
.
categories
[
c
]
+
"
}
"
+
"
{exam}
\n
"
digest
+=
f
"
{
tmp
}{
count
}
questions for
{
score
}
points
\n\t\t
%
\\
copygroup[
{
count
}
]
"
+
"
{
"
+
self
.
categories
[
c
]
+
"
}
"
+
"
{exam}
\n
"
return
digest
+
"
\t\t
%\shufflegroup{exam}
\n\t\t
%\insertgroup{exam}
\n\n
"
+
res
digest
+=
"
\t\t
\shufflegroup{exam}
\n\t\t
\insertgroup{exam}
\n
"
digest
+=
f
"
%
{
totalq
}
questions for a total of
{
totalpoints
}
points
\n
"
if
model
==
None
:
model
=
path
[
0
]
+
"
/model.tex
"
f
=
open
(
model
,
"
r
"
)
model
=
f
.
read
()
f
.
close
()
output_f
=
open
(
output_path
[:
-
7
]
+
"
.tex
"
,
"
w
"
)
output_f
.
write
(
model
.
replace
(
"
\\
begin{document}
"
,
"
\\
begin{document}
\n\\
input{
"
+
output_path
+
"
}
"
).
replace
(
"
%%%Exam content%%%
"
,
digest
))
output_f
.
close
()
def
save
(
self
):
def
save
(
self
):
name
=
self
.
file_name
[
self
.
file_name
.
rfind
(
'
/
'
)
+
1
:
self
.
file_name
.
rfind
(
'
.
'
)]
name
=
self
.
file_name
[
self
.
file_name
.
rfind
(
'
/
'
)
+
1
:
self
.
file_name
.
rfind
(
'
.
'
)]
output
=
open
(
self
.
folder
+
"
/
"
+
name
+
"
.tex
"
,
"
w
"
)
output
=
open
(
self
.
folder
+
name
+
"
.
db.
tex
"
,
"
w
"
)
output
.
write
(
self
.
__str__
())
output
.
write
(
self
.
__str__
())
output
.
close
()
self
.
get_exam
(
self
.
folder
+
name
+
"
.db.tex
"
)
class
Question
:
class
Question
:
def
__init__
(
self
,
xmlQ
,
c
,
n
,
f
,
x
,
r
=
False
):
def
__init__
(
self
,
xmlQ
,
c
,
n
,
f
,
x
,
r
=
False
):
...
...
This diff is collapsed.
Click to expand it.
model.tex
0 → 100644
+
29
−
0
View file @
8ce9214b
\documentclass
{
Exam-QCM
}
%perso
\usepackage
[utf8x]
{
inputenc
}
\usepackage
[T1]
{
fontenc
}
\usepackage
[lang=EN,box,completemulti]
{
automultiplechoice
}
%multiple choice
\usepackage
[french,english]
{
babel
}
\PrerenderUnicode
{
°—
}
%pour les en-têtes
\usepackage
{
commandesPerso
}
%perso contains \multiling
\title
{
TODO
}
\subtitle
{
TODO
}
\author
{
TODO
}
\public
{
TODO
}
\institution
{
TODO
}
\date
{
TODO
}
\docs
{
Tous documents papier autorisés.
}
\noteMax
{
20
}
%\xtraComment{}
\qrm
\id
\duree
{
90
}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Composition de l'examen %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{examcopy}
[1]
\maketitle
%en-têtes
%%%Exam content%%%
\AMCcleardoublepage
%Pour l'impression recto-verso
\end{examcopy}
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment