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
54eef09c
Commit
54eef09c
authored
3 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
better id
parent
beac46bf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
XML_Moodle.py
+2
-2
2 additions, 2 deletions
XML_Moodle.py
utils.py
+8
-2
8 additions, 2 deletions
utils.py
with
10 additions
and
4 deletions
XML_Moodle.py
+
2
−
2
View file @
54eef09c
...
...
@@ -58,7 +58,7 @@ class Question:
self
.
folder
=
f
self
.
q
=
strip_tags
(
mlang_2_multiling
(
xmlQ
.
find
(
"
questiontext/text
"
).
text
),
self
.
folder
)
self
.
category
=
c
self
.
id
=
f
"
{
c
[
c
.
rfind
(
'
:
'
)+1
:
]
}
_
{
n
}
"
self
.
id
=
mlang_2_multiling
(
xmlQ
.
find
(
"
name/text
"
).
text
,
"
en
"
)
+
f
"
:
{
n
}
"
self
.
env
=
"
todo:
"
+
xmlQ
.
attrib
[
"
type
"
]
self
.
max
=
float
(
xmlQ
.
find
(
"
defaultgrade
"
).
text
)
self
.
parseImages
(
xmlQ
.
findall
(
"
.//file
"
))
...
...
@@ -178,7 +178,7 @@ class ShortAnswer(TF):
return
res
if
__name__
==
"
__main__
"
:
quizz
=
Quizz
(
"
data/quiz-GI-4-SID-S1-top-20201204-1620.xml
"
,
"
data
"
)
quizz
=
Quizz
(
"
data/quiz-GI-4-SID-S1-top-20201204-1620
_corrigé
.xml
"
,
"
data
"
)
#quizz = Quizz("data/quiz-GI-4.xml" , "data")
#print(quizz)
quizz
.
save
()
This diff is collapsed.
Click to expand it.
utils.py
+
8
−
2
View file @
54eef09c
...
...
@@ -34,8 +34,14 @@ def remove_moodle_cdata(txt, folder):
def
strip_tags
(
txt
,
folder
):
return
html_2_tex
(
sub
(
compile
(
'
<.*?>
'
),
''
,
remove_moodle_cdata
(
unquote
(
txt
),
folder
)))
def
mlang_2_multiling
(
txt
):
return
sub
(
r
"
\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}
"
,
r
"
\\multiling{\6}{\1}
"
,
txt
)
def
mlang_2_multiling
(
txt
,
which
=
"
both
"
):
if
which
==
"
fr
"
:
res
=
sub
(
r
"
\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}
"
,
r
"
\6
"
,
txt
)
elif
which
==
"
en
"
:
res
=
sub
(
r
"
\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}
"
,
r
"
\1
"
,
txt
)
else
:
res
=
sub
(
r
"
\{mlang\s*en\}([^\{]*?)\{mlang\}\s*((\{mlang\s*other\})|(\{mlang\s*fr\})|(\{mlang\}))([^\{]*)\{mlang\}
"
,
r
"
\\multiling{\6}{\1}
"
,
txt
)
return
res
def
score_2_str
(
v
):
if
int
(
v
)
==
float
(
v
):
...
...
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