Commit ef5d7e48 authored by Jérémie Passerat's avatar Jérémie Passerat

Cycle complet xml numerique

parent 9339d9c6
......@@ -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")
newAnswer = SubElement(question, "answer")
newAnswer.attrib["fraction"] = elements_contenu["liste_note"][i]
newAnswer.attrib["format"] = "moodle_auto_format"
text = SubElement(newAnswer, "text")
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(newAnswer, "feedback")
textFeedback = SubElement(feedback, "text")
textFeedback.text = elements_contenu["liste_feedback"][i]
feedback = SubElement(new_answer, "feedback")
text_feedback = SubElement(feedback, "text")
text_feedback.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")
newAnswer = SubElement(question, "answer")
newAnswer.attrib["fraction"] = elements_contenu["liste_note"][i]
newAnswer.attrib["format"] = "html"
text = SubElement(newAnswer, "text")
new_answer = SubElement(question, "answer")
new_answer.attrib["fraction"] = elements_contenu["liste_note"][i]
new_answer.attrib["format"] = "html"
text = SubElement(new_answer, "text")
text.text = elements_contenu["liste_reponse"][i]
feedback = SubElement(newAnswer, "feedback")
textFeedback = SubElement(feedback, "text")
textFeedback.text = elements_contenu["liste_feedback"][i]
feedback = SubElement(new_answer, "feedback")
text_feedback = SubElement(feedback, "text")
text_feedback.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"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment