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:
i
+=
1
print
(
"A la sortie, i = "
,
i
)
print
(
"J'ai "
,
len
(
elements_contenu
[
"liste_reponse"
]),
" reponses"
)
print
(
"A la sortie, i = "
,
i
)
print
(
"J'ai "
,
len
(
elements_contenu
[
"liste_reponse"
]),
" reponses"
)
if
i
<
len
(
elements_contenu
[
"liste_reponse"
]):
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
for
question
in
root
.
iter
(
'question'
):
# eltQuestion = root.iter("question")
new
A
nswer
=
SubElement
(
question
,
"answer"
)
new
A
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
A
nswer
.
attrib
[
"format"
]
=
"moodle_auto_format"
text
=
SubElement
(
new
A
nswer
,
"text"
)
new
_a
nswer
=
SubElement
(
question
,
"answer"
)
new
_a
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
_a
nswer
.
attrib
[
"format"
]
=
"moodle_auto_format"
text
=
SubElement
(
new
_a
nswer
,
"text"
)
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
feedback
=
SubElement
(
new
A
nswer
,
"feedback"
)
text
F
eedback
=
SubElement
(
feedback
,
"text"
)
text
F
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
feedback
=
SubElement
(
new
_a
nswer
,
"feedback"
)
text
_f
eedback
=
SubElement
(
feedback
,
"text"
)
text
_f
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
i
+=
1
# # for k in range(3):
...
...
@@ -1028,74 +1028,95 @@ class ContenuDao:
answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
for
question
in
answer
.
iter
(
'text'
):
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
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"
]):
print
(
"Je le ai "
,
len
(
elements_contenu
[
"liste_reponse"
])
-
i
,
" nouveaux contenus"
)
for
question
in
root
.
iter
(
'question'
):
# eltQuestion = root.iter("question")
new
A
nswer
=
SubElement
(
question
,
"answer"
)
new
A
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
A
nswer
.
attrib
[
"format"
]
=
"html"
text
=
SubElement
(
new
A
nswer
,
"text"
)
new
_a
nswer
=
SubElement
(
question
,
"answer"
)
new
_a
nswer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
new
_a
nswer
.
attrib
[
"format"
]
=
"html"
text
=
SubElement
(
new
_a
nswer
,
"text"
)
text
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
feedback
=
SubElement
(
new
A
nswer
,
"feedback"
)
text
F
eedback
=
SubElement
(
feedback
,
"text"
)
text
F
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
feedback
=
SubElement
(
new
_a
nswer
,
"feedback"
)
text
_f
eedback
=
SubElement
(
feedback
,
"text"
)
text
_f
eedback
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
i
+=
1
elif
elements_contenu
[
"type_question"
]
==
"numerical"
or
\
elements_contenu
[
"type_question"
]
==
"calculatedsimple"
:
pass
# for unit in root.iter('unitgradingtype'):
# elements_question["traitement_unite"] = unit.text
#
# for showunits in root.iter('showunits'):
# elements_question["saisie_unite"] = showunits.text
#
# for unitsleft in root.iter('unitsleft'):
# elements_question["position_unite"] = unitsleft.text
#
# liste_unite_nom = []
# for unit_name in root.iter('unit_name'):
# liste_unite_nom.append(unit_name.text)
# for k in range(3):
# liste_unite_nom.append('')
#
# liste_unite_coef = []
# for multiplier in root.iter('multiplier'):
# liste_unite_coef.append(multiplier.text)
# for k in range(3):
# liste_unite_coef.append('')
#
# elements_question["liste_unite_nom"] = liste_unite_nom
# elements_question["liste_unite_coef"] = liste_unite_coef
#
# liste_reponse = []
# liste_note = []
# liste_feedback = []
# liste_tolerance = []
# for answer in root.iter('answer'):
# liste_note.append(answer.attrib["fraction"])
# for question in answer.iter('text'):
# if question.text is not None:
# liste_reponse.append(question.text)
# for feedback in answer.iter('feedback'):
# for feed in feedback.iter('text'):
# liste_feedback.append(feed.text)
# for tolerance in answer.iter('tolerance'):
# #print ("tolerance : ", tolerance.text)
# if tolerance.text is not None:
# liste_tolerance.append(tolerance.text)
#
# elements_question["liste_reponse"] = liste_reponse
# elements_question["liste_note"] = liste_note
# elements_question["liste_feedback"] = liste_feedback
# elements_question["liste_tolerance"] = liste_tolerance
for
unit
in
root
.
iter
(
'unitgradingtype'
):
unit
.
text
=
elements_contenu
[
"traitement_unite"
]
for
showunits
in
root
.
iter
(
'showunits'
):
showunits
.
text
=
elements_contenu
[
"saisie_unite"
]
for
unitsleft
in
root
.
iter
(
'unitsleft'
):
unitsleft
.
text
=
elements_contenu
[
"position_unite"
]
i
=
0
for
unit_name
in
root
.
iter
(
'unit_name'
):
if
unit_name
is
not
None
:
unit_name
.
text
=
elements_contenu
[
"liste_unite_nom"
][
i
]
i
+=
1
i
=
0
for
multiplier
in
root
.
iter
(
'multiplier'
):
if
multiplier
is
not
None
:
multiplier
.
text
=
elements_contenu
[
"liste_unite_coef"
][
i
]
i
+=
1
# on ajoute les éventuelles nouvelles unités
if
i
<
len
(
elements_contenu
[
"liste_unite_nom"
]):
for
question
in
root
.
iter
(
'question'
):
for
unit
in
question
.
iter
(
'units'
):
print
(
"1. : "
,
str
(
ET
.
tostring
(
unit
)))
new_unit
=
SubElement
(
unit
,
"unit"
)
multiplier
=
SubElement
(
new_unit
,
"multiplier"
)
multiplier
.
text
=
elements_contenu
[
"liste_unite_coef"
][
i
]
unit_name
=
SubElement
(
new_unit
,
"unit_name"
)
unit_name
.
text
=
elements_contenu
[
"liste_unite_nom"
][
i
]
# print("Je le ai ", len(elements_contenu["liste_note"]), " notes, ", len(elements_contenu["liste_feedback"]), " feedbacks, ",
# len(elements_contenu["liste_reponse"]), " reponses et ", len(elements_contenu["liste_tolerance"]), "tolerances")
i
=
0
for
answer
in
root
.
iter
(
'answer'
):
answer
.
attrib
[
"fraction"
]
=
elements_contenu
[
"liste_note"
][
i
]
for
question
in
answer
.
iter
(
'text'
):
if
question
.
text
is
not
None
:
question
.
text
=
elements_contenu
[
"liste_reponse"
][
i
]
for
feedback
in
answer
.
iter
(
'feedback'
):
for
feed
in
feedback
.
iter
(
'text'
):
feed
.
text
=
elements_contenu
[
"liste_feedback"
][
i
]
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
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