Commit 522da359 by Alan Boudreault

Fix lightchild data loading

parent 125eeb30
......@@ -56,7 +56,7 @@ class HTMLBlock(LightChild):
return block
def student_view(self, context=None):
# HACK, TO MODIFY
# TODO HACK, TO MODIFY, SHOULDN'T USE A get() METHOD
return Fragment(self.content.get())
def mentoring_view(self, context=None):
......
......@@ -209,8 +209,6 @@ class LightChild(Plugin, LightChildrenMixin):
def __init__(self, parent):
self.parent = parent
self.xblock_container = parent.xblock_container
# This doesn't work, crash.... where should I trigger the lazy property to be loaded?
#self.load_student_data()
def __setattr__(self, name, value):
......@@ -255,8 +253,10 @@ class LightChild(Plugin, LightChildrenMixin):
"""
Load the values from the student_data in the database.
"""
if not self.student_data:
return
student_data = self.student_data
student_data = json.loads(self.student_data)
fields = self.get_fields()
for field in fields:
if field in student_data:
......
......@@ -46,12 +46,14 @@ class MRQBlock(QuestionnaireAbstractBlock):
max_attempts = Integer(help="Number of max attempts for this questions", default=None, scope=Scope.content)
num_attempts = Integer(help="Number of attempts a user has answered for this questions", scope=Scope.user_state)
# TODO REMOVE THIS, ONLY NEEDED FOR LIGHTCHILDREN
@classmethod
def get_fields(cls):
return [
'num_attempts'
]
# TODO REMOVE ALL USE OF THE get() METHOD
def submit(self, submissions):
log.debug(u'Received MRQ submissions: "%s"', submissions)
......
......@@ -73,6 +73,10 @@ class QuestionnaireAbstractBlock(LightChild):
def mentoring_view(self, context=None):
name = self.__class__.__name__
# Ensure our data are loaded from the db
# TODO HACK, TO REMOVE.
self.load_student_data()
if str(self.type) not in self.valid_types:
raise ValueError, u'Invalid value for {}.type: `{}`'.format(name, self.type)
......
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