में मोंगोइंजिन के डायनेमिकएम्बेड डॉक्यूमेंट को संभालना मुझे एक समस्या है जिसके लिए मुझे मोंगोइंजिन के साथ फ्लास्क-एडमिन का उपयोग करके एक सरल समाधान नहीं मिल रहा है। मेरे पास ExerciseResourceContent
नामक एक दस्तावेज़ श्रेणी है।फ्लास्क-एडमिन
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()
यह दो वर्गों में subclassed जा सकता है (और अधिक करने के लिए:
class ExerciseResourceContent(ResourceContent):
"""An exercise with a list of questions."""
## Embedded list of questions
questions = db.ListField(db.EmbeddedDocumentField(ExerciseQuestion))
ExerciseQuestion
दस्तावेज़ वास्तव में एक DynamicEmbeddedDocument
है: यह एक "सवाल" विशेषता है, जो एक EmbeddedDocument
के ListField
बुलाया ExerciseQuestion
है आ): 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()
जब मैं ExerciseResourceContent
बनाने या संपादित करने के लिए फ्लास्क-एडमिन का उपयोग करता हूं, तो यह एक "प्रश्न" सूची प्रदर्शित करता है, जिसमें से मैं "Question_text" विशेषता संपादित कर सकता हूं, लेकिन मुझे "Correct_Answer" विशेषता नहीं दिखाई दे सकती है, न ही कोई "प्रस्ताव" विशेषता जैसा मैं चाहता था मैंने फ्लास्क-एडमिन दस्तावेज़ से संघर्ष किया, लेकिन ऐसा लगता है कि यह गतिशील सामग्री (फ़ील्ड या दस्तावेज़) के साथ एक समस्या है, और दस्तावेज़ों में इसके बारे में कुछ भी नहीं है।
आपकी मदद के लिए धन्यवाद
इस कोड को हो सकता है प्रश्न का उत्तर दें, इस कोड का उत्तर देने के तरीके के बारे में अतिरिक्त संदर्भ प्रदान करना और/या कैसे यह दीर्घकालिक मूल्य में सुधार करता है। –