Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenQuizz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Weber Rodolphe
OpenQuizz
Commits
ef5d7e48
Commit
ef5d7e48
authored
Sep 24, 2021
by
Jérémie Passerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cycle complet xml numerique
parent
9339d9c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
63 deletions
+84
-63
contenu_dao.py
modele/contenu_dao.py
+84
-63
No files found.
modele/contenu_dao.py
View file @
ef5d7e48
...
@@ -985,21 +985,21 @@ class ContenuDao:
...
@@ -985,21 +985,21 @@ class ContenuDao:
i
+=
1
i
+=
1
print
(
"A la sortie, i = "
,
i
)
print
(
"A la sortie, i = "
,
i
)
print
(
"J'ai "
,
len
(
elements_contenu
[
"liste_reponse"
]),
" reponses"
)
print
(
"J'ai "
,
len
(
elements_contenu
[
"liste_reponse"
]),
" reponses"
)
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
for
question
in
root
.
iter
(
'question'
):
for
question
in
root
.
iter
(
'question'
):
# eltQuestion = root.iter("question")
# eltQuestion = root.iter("question")
new
A
nswer
=
SubElement
(
question
,
"answer"
)
new
_a
nswer
=
SubElement
(
question
,
"answer"
)
new
A
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
_a
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
A
nswer
.
attrib
[
"format"
]
=
"moodle_auto_format"
new
_a
nswer
.
attrib
[
"format"
]
=
"moodle_auto_format"
text
=
SubElement
(
new
A
nswer
,
"text"
)
text
=
SubElement
(
new
_a
nswer
,
"text"
)
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
feedback
=
SubElement
(
new
A
nswer
,
"feedback"
)
feedback
=
SubElement
(
new
_a
nswer
,
"feedback"
)
text
F
eedback
=
SubElement
(
feedback
,
"text"
)
text
_f
eedback
=
SubElement
(
feedback
,
"text"
)
text
F
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
text
_f
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
i
+=
1
i
+=
1
# # for k in range(3):
# # for k in range(3):
...
@@ -1028,74 +1028,95 @@ class ContenuDao:
...
@@ -1028,74 +1028,95 @@ class ContenuDao:
answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
for
question
in
answer
.
iter
(
'text'
):
for
question
in
answer
.
iter
(
'text'
):
if
question
.
text
is
not
None
:
if
question
.
text
is
not
None
:
question
.
text
=
elements_contenu
[
"liste_
question
"
][
i
]
question
.
text
=
elements_contenu
[
"liste_
reponse
"
][
i
]
for
feedback
in
answer
.
iter
(
'feedback'
):
for
feedback
in
answer
.
iter
(
'feedback'
):
for
feed
in
feedback
.
iter
(
'text'
):
for
feed
in
feedback
.
iter
(
'text'
):
feed
.
text
=
elements_contenu
[
"liste_feedback"
][
0
]
feed
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
i
+=
1
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
for
question
in
root
.
iter
(
'question'
):
for
question
in
root
.
iter
(
'question'
):
# eltQuestion = root.iter("question")
# eltQuestion = root.iter("question")
new
A
nswer
=
SubElement
(
question
,
"answer"
)
new
_a
nswer
=
SubElement
(
question
,
"answer"
)
new
A
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
_a
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
A
nswer
.
attrib
[
"format"
]
=
"html"
new
_a
nswer
.
attrib
[
"format"
]
=
"html"
text
=
SubElement
(
new
A
nswer
,
"text"
)
text
=
SubElement
(
new
_a
nswer
,
"text"
)
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
feedback
=
SubElement
(
new
A
nswer
,
"feedback"
)
feedback
=
SubElement
(
new
_a
nswer
,
"feedback"
)
text
F
eedback
=
SubElement
(
feedback
,
"text"
)
text
_f
eedback
=
SubElement
(
feedback
,
"text"
)
text
F
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
text
_f
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
i
+=
1
i
+=
1
elif
elements_contenu
[
"type_question"
]
==
"numerical"
or
\
elif
elements_contenu
[
"type_question"
]
==
"numerical"
or
\
elements_contenu
[
"type_question"
]
==
"calculatedsimple"
:
elements_contenu
[
"type_question"
]
==
"calculatedsimple"
:
pass
pass
# for unit in root.iter('unitgradingtype'):
for
unit
in
root
.
iter
(
'unitgradingtype'
):
# elements_question["traitement_unite"] = unit.text
unit
.
text
=
elements_contenu
[
"traitement_unite"
]
#
# for showunits in root.iter('showunits'):
for
showunits
in
root
.
iter
(
'showunits'
):
# elements_question["saisie_unite"] = showunits.text
showunits
.
text
=
elements_contenu
[
"saisie_unite"
]
#
# for unitsleft in root.iter('unitsleft'):
for
unitsleft
in
root
.
iter
(
'unitsleft'
):
# elements_question["position_unite"] = unitsleft.text
unitsleft
.
text
=
elements_contenu
[
"position_unite"
]
#
# liste_unite_nom = []
i
=
0
# for unit_name in root.iter('unit_name'):
for
unit_name
in
root
.
iter
(
'unit_name'
):
# liste_unite_nom.append(unit_name.text)
if
unit_name
is
not
None
:
# for k in range(3):
unit_name
.
text
=
elements_contenu
[
"liste_unite_nom"
][
i
]
# liste_unite_nom.append('')
i
+=
1
#
# liste_unite_coef = []
i
=
0
# for multiplier in root.iter('multiplier'):
for
multiplier
in
root
.
iter
(
'multiplier'
):
# liste_unite_coef.append(multiplier.text)
if
multiplier
is
not
None
:
# for k in range(3):
multiplier
.
text
=
elements_contenu
[
"liste_unite_coef"
][
i
]
# liste_unite_coef.append('')
i
+=
1
#
# elements_question["liste_unite_nom"] = liste_unite_nom
# on ajoute les éventuelles nouvelles unités
# elements_question["liste_unite_coef"] = liste_unite_coef
if
i
<
len
(
elements_contenu
[
"liste_unite_nom"
]):
#
for
question
in
root
.
iter
(
'question'
):
# liste_reponse = []
for
unit
in
question
.
iter
(
'units'
):
# liste_note = []
print
(
"1. : "
,
str
(
ET
.
tostring
(
unit
)))
# liste_feedback = []
new_unit
=
SubElement
(
unit
,
"unit"
)
# liste_tolerance = []
multiplier
=
SubElement
(
new_unit
,
"multiplier"
)
# for answer in root.iter('answer'):
multiplier
.
text
=
elements_contenu
[
"liste_unite_coef"
][
i
]
# liste_note.append(answer.attrib["fraction"])
unit_name
=
SubElement
(
new_unit
,
"unit_name"
)
# for question in answer.iter('text'):
unit_name
.
text
=
elements_contenu
[
"liste_unite_nom"
][
i
]
# if question.text is not None:
# liste_reponse.append(question.text)
# print("Je le ai ", len(elements_contenu["liste_note"]), " notes, ", len(elements_contenu["liste_feedback"]), " feedbacks, ",
# for feedback in answer.iter('feedback'):
# len(elements_contenu["liste_reponse"]), " reponses et ", len(elements_contenu["liste_tolerance"]), "tolerances")
# for feed in feedback.iter('text'):
# liste_feedback.append(feed.text)
i
=
0
# for tolerance in answer.iter('tolerance'):
for
answer
in
root
.
iter
(
'answer'
):
# #print ("tolerance : ", tolerance.text)
answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
# if tolerance.text is not None:
for
question
in
answer
.
iter
(
'text'
):
# liste_tolerance.append(tolerance.text)
if
question
.
text
is
not
None
:
#
question
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
# elements_question["liste_reponse"] = liste_reponse
for
feedback
in
answer
.
iter
(
'feedback'
):
# elements_question["liste_note"] = liste_note
for
feed
in
feedback
.
iter
(
'text'
):
# elements_question["liste_feedback"] = liste_feedback
feed
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
# elements_question["liste_tolerance"] = liste_tolerance
for
tolerance
in
answer
.
iter
(
'tolerance'
):
if
tolerance
.
text
is
not
None
:
tolerance
.
text
=
elements_contenu
[
"liste_tolerance"
][
i
]
i
+=
1
# on ajoute les éventuelles nouvelles réponses
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
for
question
in
root
.
iter
(
'question'
):
# eltQuestion = root.iter("question")
new_answer
=
SubElement
(
question
,
"answer"
)
new_answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new_answer
.
attrib
[
"format"
]
=
"moodle_auto_format"
text
=
SubElement
(
new_answer
,
"text"
)
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
feedback
=
SubElement
(
new_answer
,
"feedback"
)
feedback
.
attrib
[
"format"
]
=
"html"
text_feedback
=
SubElement
(
feedback
,
"text"
)
text_feedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
tolerance
=
SubElement
(
new_answer
,
"tolerance"
)
tolerance
.
text
=
elements_contenu
[
"liste_tolerance"
][
i
]
i
+=
1
# on maj le fichier du contenu
# on maj le fichier du contenu
Utils
()
.
changer_texte_fichier
(
ObjectId
(
id_contenu
),
ET
.
tostring
(
root
)
.
decode
(
"utf-8"
),
Utils
()
.
changer_texte_fichier
(
ObjectId
(
id_contenu
),
ET
.
tostring
(
root
)
.
decode
(
"utf-8"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment