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
4420db3d
Commit
4420db3d
authored
3 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
nb points
parent
111b0b92
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
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
XML_Moodle.py
+19
-13
19 additions, 13 deletions
XML_Moodle.py
utils.py
+7
-0
7 additions, 0 deletions
utils.py
with
27 additions
and
14 deletions
.gitignore
+
1
−
1
View file @
4420db3d
quiz-
GI-4-SID-S1-top-20201204-1620
.xml
quiz-
*
.xml
__pycache__
__pycache__
This diff is collapsed.
Click to expand it.
XML_Moodle.py
+
19
−
13
View file @
4420db3d
#!/usr/bin/env python3
#!/usr/bin/env python3
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
from
utils
import
strip_tags
,
mlang_2_multiling
from
utils
import
strip_tags
,
mlang_2_multiling
,
score_2_str
class
Quizz
:
class
Quizz
:
def
__init__
(
self
,
file_name
):
def
__init__
(
self
,
file_name
):
self
.
file_name
=
file_name
self
.
file_name
=
file_name
self
.
tree
=
ET
.
parse
(
self
.
file_name
)
self
.
tree
=
ET
.
parse
(
self
.
file_name
)
self
.
questions
=
[]
self
.
questions
=
{}
self
.
parse
()
self
.
parse
()
def
get_tree
(
self
):
def
get_tree
(
self
):
...
@@ -17,33 +17,39 @@ class Quizz:
...
@@ -17,33 +17,39 @@ class Quizz:
if
q
.
attrib
[
"
type
"
]
==
"
category
"
:
if
q
.
attrib
[
"
type
"
]
==
"
category
"
:
c
=
q
.
find
(
"
category/text
"
).
text
.
replace
(
"
$course$/top/
"
,
""
).
replace
(
"
/
"
,
"
:
"
).
replace
(
"
::
"
,
"
/
"
)
c
=
q
.
find
(
"
category/text
"
).
text
.
replace
(
"
$course$/top/
"
,
""
).
replace
(
"
/
"
,
"
:
"
).
replace
(
"
::
"
,
"
/
"
)
else
:
else
:
self
.
questions
.
append
(
Question
(
q
,
c
))
if
c
not
in
self
.
questions
.
keys
():
self
.
questions
[
c
]
=
[]
self
.
questions
[
c
].
append
(
Question
(
q
,
c
,
len
(
self
.
questions
[
c
])))
def
__str__
(
self
):
def
__str__
(
self
):
res
=
""
res
=
""
for
q
in
self
.
questions
:
for
c_q
in
self
.
questions
.
values
():
res
+=
str
(
q
)
for
q
in
c_q
:
res
+=
str
(
q
)
return
res
return
res
class
Question
:
class
Question
:
def
__init__
(
self
,
xmlQ
,
c
):
def
__init__
(
self
,
xmlQ
,
c
,
n
):
self
.
q
=
mlang_2_multiling
(
strip_tags
(
xmlQ
.
find
(
"
questiontext/text
"
).
text
))
self
.
q
=
mlang_2_multiling
(
strip_tags
(
xmlQ
.
find
(
"
questiontext/text
"
).
text
))
self
.
category
=
c
self
.
category
=
c
self
.
id
=
f
"
{
c
[
c
.
rfind
(
'
:
'
)+1
:
]
}
_
{
n
}
"
self
.
max
=
float
(
xmlQ
.
find
(
"
defaultgrade
"
).
text
)
def
__str__
(
self
):
def
__str__
(
self
):
return
"""
\\
element{
"""
+
self
.
category
+
"""
}{
return
"""
\\
element{
"""
+
self
.
category
+
"""
}{
\\
begin{questionmult}{
Def}
\\
nbpoints{0,5
}
\\
begin{questionmult}{
"""
+
self
.
id
+
"""
}
\\
nbpoints{
"""
+
score_2_str
(
self
.
max
)
+
"""
}
"""
+
self
.
q
+
"""
"""
+
self
.
q
+
"""
\\
begin{choices}
\\
begin{choices}
\\
correctchoice{L
'
utilisation d
'
un traitement de texte en cours de langue.}
\b
areme{b=0.25}
\\
correctchoice{L
'
utilisation d
'
un traitement de texte en cours de langue.}
\
\
bareme{b=0.25}
\\
correctchoice{L
'
évaluation de l
'
interface d
'
un concordancier en vue de son utilisation en classe d
'
anglais.}
\b
areme{b=0.15}
\\
correctchoice{L
'
évaluation de l
'
interface d
'
un concordancier en vue de son utilisation en classe d
'
anglais.}
\
\
bareme{b=0.15}
\\
correctchoice{L
'
utilisation d
'
un glossaire en ligne sur l
'
informatique en cours de FLE.}
\b
areme{b=0.15}
\\
correctchoice{L
'
utilisation d
'
un glossaire en ligne sur l
'
informatique en cours de FLE.}
\
\
bareme{b=0.15}
\\
wrongchoice{L
'
utilisation d
'
un dictionnaire en cours d
'
anglais.}
\b
areme{b=0,m=-0.25}
\\
wrongchoice{L
'
utilisation d
'
un dictionnaire en cours d
'
anglais.}
\
\
bareme{b=0,m=-0.25}
\\
wrongchoice{La création d
'
un glossaire en ligne sur l
'
informatique.}
\b
areme{b=0}
\\
wrongchoice{La création d
'
un glossaire en ligne sur l
'
informatique.}
\
\
bareme{b=0}
\\
end{choices}
\\
end{choices}
\\
explain{La création d
'
un lexique ne relève pas intrinsèquement de l
'
ALAO, encore faut-il que son usage soit lié à l
'
apprentissage d
'
une langue.}
\\
explain{La création d
'
un lexique ne relève pas intrinsèquement de l
'
ALAO, encore faut-il que son usage soit lié à l
'
apprentissage d
'
une langue.}
\\
end{questionmult}
\\
end{questionmult}
}
\n\n
"""
}
\n\n
"""
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
quizz
=
Quizz
(
"
quiz-GI-4-SID-S1-top-20201204-1620.xml
"
)
# quizz = Quizz("quiz-GI-4-SID-S1-top-20201204-1620.xml")
quizz
=
Quizz
(
"
quiz-GI-4.xml
"
)
print
(
quizz
)
print
(
quizz
)
This diff is collapsed.
Click to expand it.
utils.py
+
7
−
0
View file @
4420db3d
...
@@ -9,3 +9,10 @@ def strip_tags(txt):
...
@@ -9,3 +9,10 @@ def strip_tags(txt):
def
mlang_2_multiling
(
txt
):
def
mlang_2_multiling
(
txt
):
return
sub
(
r
"
\{mlang en\}(.*?)\{mlang\}\{mlang other\}(.*?)\{mlang\}
"
,
r
"
\\multiling{\2}{\1}
"
,
txt
)
return
sub
(
r
"
\{mlang en\}(.*?)\{mlang\}\{mlang other\}(.*?)\{mlang\}
"
,
r
"
\\multiling{\2}{\1}
"
,
txt
)
def
score_2_str
(
v
):
if
int
(
v
)
==
float
(
v
):
res
=
str
(
int
(
v
))
else
:
res
=
str
(
float
(
v
))
return
res
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