Fré*_*ade 16 python mongoengine flask flask-admin
我有一个问题,我找不到一个简单的解决方案,使用Flask-Admin和MongoEngine.我有一个名为的Document类ExerciseResourceContent.它有一个"问题"属性,它是一个ListField一个的EmbeddedDocument叫ExerciseQuestion:
class ExerciseResourceContent(ResourceContent):
"""An exercise with a list of questions."""
## Embedded list of questions
questions = db.ListField(db.EmbeddedDocumentField(ExerciseQuestion))
Run Code Online (Sandbox Code Playgroud)
该ExerciseQuestion文件实际上是DynamicEmbeddedDocument:
class ExerciseQuestion(db.DynamicEmbeddedDocument):
"""
Generic collection, every question type will inherit from this.
Subclasses should override method "without_correct_answer" in order to define the version sent to clients.
Subclasses of questions depending on presentation parameters should also override method "with_computed_correct_answer".
"""
_id = db.ObjectIdField(default=ObjectId)
## Question text
question_text = db.StringField(required=True)
## Correct answer (field type depends on question type)
correct_answer = db.DynamicField()
Run Code Online (Sandbox Code Playgroud)
它可以分为两类(更多来自):MultipleAnswerMCQExerciseQuestion和UniqueAnswerMCQExerciseQuestion:
class MultipleAnswerMCQExerciseQuestion(ExerciseQuestion):
"""Multiple choice question with several possible answers."""
## Propositions
propositions = db.ListField(db.EmbeddedDocumentField(MultipleAnswerMCQExerciseQuestionProposition))
## Correct answer
correct_answer = db.ListField(db.ObjectIdField())
class UniqueAnswerMCQExerciseQuestion(ExerciseQuestion):
"""Multiple choice question with one possible answer only."""
## Propositions
propositions = db.ListField(db.EmbeddedDocumentField(UniqueAnswerMCQExerciseQuestionProposition))
## Correct answer
correct_answer = db.ObjectIdField()
Run Code Online (Sandbox Code Playgroud)
当我使用Flask-Admin创建或编辑一个时ExerciseResourceContent,它会显示一个"问题"列表,我可以从中编辑"Question_text"属性,但我看不到"Correct_Answer"属性,也没有任何"Propositions"属性,因为我将.我在使用Flask-Admin文档时遇到了困难,但似乎动态内容(字段或文档)存在问题,而且文档中没有任何内容.
谢谢你的帮助
小智 0
import time
sentence = "ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY"
s = sentence.split()
another = [0]
time.sleep(0.5)
print(sentence)
for count, i in enumerate(s):
if s.count(i) < 2:
another.append(max(another) + 1)
else:
another.append(s.index(i) +1)
another.remove(0)
time.sleep(0.5)
print(another)
file = open("N:\(Filedirectory)","w")
file.write(another)
file.write(s)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
789 次 |
| 最近记录: |