本文整理汇总了Python中xmodule.progress.Progress.to_js_status_str方法的典型用法代码示例。如果您正苦于以下问题:Python Progress.to_js_status_str方法的具体用法?Python Progress.to_js_status_str怎么用?Python Progress.to_js_status_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmodule.progress.Progress
的用法示例。
在下文中一共展示了Progress.to_js_status_str方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_js_status
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def test_to_js_status(self):
'''Test the Progress.to_js_status_str() method'''
self.assertEqual(Progress.to_js_status_str(self.not_started), "none")
self.assertEqual(Progress.to_js_status_str(self.half_done), "in_progress")
self.assertEqual(Progress.to_js_status_str(self.done), "done")
self.assertEqual(Progress.to_js_status_str(None), "0")
示例2: handle_ajax
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def handle_ajax(self, dispatch, data, system):
'''
This is called by courseware.module_render, to handle an AJAX call.
"data" is request.POST.
Returns a json dictionary:
{ 'progress_changed' : True/False,
'progress' : 'none'/'in_progress'/'done',
<other request-specific values here > }
'''
handlers = {
'save_answer': self.save_answer,
'score_update': self.update_score,
'save_post_assessment': self.message_post,
'skip_post_assessment': self.skip_post_assessment,
'check_for_score': self.check_for_score,
'store_answer': self.store_answer,
}
_ = self.system.service(self, "i18n").ugettext
if dispatch not in handlers:
# This is a dev_facing_error
log.error("Cannot find {0} in handlers in handle_ajax function for open_ended_module.py".format(dispatch))
# This is a dev_facing_error
return json.dumps(
{'error': _('Error handling action. Please try again.'), 'success': False}
)
before = self.get_progress()
d = handlers[dispatch](data, system)
after = self.get_progress()
d.update({
'progress_changed': after != before,
'progress_status': Progress.to_js_status_str(after),
})
return json.dumps(d, cls=ComplexEncoder)
示例3: handle_ajax
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def handle_ajax(self, dispatch, data, system):
"""
This is called by courseware.module_render, to handle an AJAX call.
"data" is request.POST.
Returns a json dictionary:
{ 'progress_changed' : True/False,
'progress' : 'none'/'in_progress'/'done',
<other request-specific values here > }
"""
handlers = {
"save_answer": self.save_answer,
"score_update": self.update_score,
"save_post_assessment": self.message_post,
"skip_post_assessment": self.skip_post_assessment,
"check_for_score": self.check_for_score,
}
if dispatch not in handlers:
# This is a dev_facing_error
log.error("Cannot find {0} in handlers in handle_ajax function for open_ended_module.py".format(dispatch))
# This is a dev_facing_error
return json.dumps({"error": "Error handling action. Please try again.", "success": False})
before = self.get_progress()
d = handlers[dispatch](data, system)
after = self.get_progress()
d.update({"progress_changed": after != before, "progress_status": Progress.to_js_status_str(after)})
return json.dumps(d, cls=ComplexEncoder)
示例4: handle_ajax
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def handle_ajax(self, dispatch, data, system):
"""
This is called by courseware.module_render, to handle an AJAX call.
"data" is request.POST.
Returns a json dictionary:
{ 'progress_changed' : True/False,
'progress': 'none'/'in_progress'/'done',
<other request-specific values here > }
"""
handlers = {
'save_answer': self.save_answer,
'save_text': self.save_text,
'save_assessment': self.save_assessment,
'save_post_assessment': self.save_hint,
'remove_file': self.remove_file
}
if dispatch not in handlers:
# This is a dev_facing_error
log.error("Cannot find {0} in handlers in handle_ajax function for open_ended_module.py".format(dispatch))
# This is a dev_facing_error
return json.dumps({'error': 'Error handling action. Please try again.', 'success': False})
before = self.get_progress()
d = handlers[dispatch](data, system)
after = self.get_progress()
d.update({
'progress_changed': after != before,
'progress_status': Progress.to_js_status_str(after),
})
return json.dumps(d, cls=ComplexEncoder)
示例5: student_view
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def student_view(self, context):
# If we're rendering this sequence, but no position is set yet,
# default the position to the first element
if self.position is None:
self.position = 1
## Returns a set of all types of all sub-children
contents = []
fragment = Fragment()
for child in self.get_display_items():
progress = child.get_progress()
rendered_child = child.render("student_view", context)
fragment.add_frag_resources(rendered_child)
childinfo = {
"content": rendered_child.content,
"title": "\n".join(
grand_child.display_name
for grand_child in child.get_children()
if grand_child.display_name is not None
),
"progress_status": Progress.to_js_status_str(progress),
"progress_detail": Progress.to_js_detail_str(progress),
"type": child.get_icon_class(),
"id": child.id,
}
if childinfo["title"] == "":
childinfo["title"] = child.display_name_with_default
contents.append(childinfo)
params = {
"items": contents,
"element_id": self.location.html_id(),
"item_id": self.id,
"position": self.position,
"tag": self.location.category,
"ajax_url": self.system.ajax_url,
}
fragment.add_content(self.system.render_template("seq_module.html", params))
return fragment
示例6: student_view
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def student_view(self, context):
# If we're rendering this sequence, but no position is set yet,
# default the position to the first element
if self.position is None:
self.position = 1
## Returns a set of all types of all sub-children
contents = []
fragment = Fragment()
for child in self.get_display_items():
progress = child.get_progress()
rendered_child = child.render('student_view', context)
fragment.add_frag_resources(rendered_child)
childinfo = {
'content': rendered_child.content,
'title': "\n".join(
grand_child.display_name
for grand_child in child.get_children()
if grand_child.display_name is not None
),
'progress_status': Progress.to_js_status_str(progress),
'progress_detail': Progress.to_js_detail_str(progress),
'type': child.get_icon_class(),
'id': child.id,
}
if childinfo['title'] == '':
childinfo['title'] = child.display_name_with_default
contents.append(childinfo)
params = {'items': contents,
'element_id': self.location.html_id(),
'item_id': self.id,
'position': self.position,
'tag': self.location.category,
'ajax_url': self.system.ajax_url,
}
fragment.add_content(self.system.render_template('seq_module.html', params))
return fragment
示例7: render
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def render(self):
# If we're rendering this sequence, but no position is set yet,
# default the position to the first element
if self.position is None:
self.position = 1
if self.rendered:
return
## Returns a set of all types of all sub-children
contents = []
for child in self.get_display_items():
progress = child.get_progress()
childinfo = {
'content': child.get_html(),
'title': "\n".join(
grand_child.display_name
for grand_child in child.get_children()
if grand_child.display_name is not None
),
'progress_status': Progress.to_js_status_str(progress),
'progress_detail': Progress.to_js_detail_str(progress),
'type': child.get_icon_class(),
'id': child.id,
'direct_term': child.direct_term_with_default
}
if childinfo['title'] == '':
childinfo['title'] = child.display_name_with_default
contents.append(childinfo)
params = {'items': contents,
'element_id': self.location.html_id(),
'item_id': self.id,
'position': self.position,
'tag': self.location.category
}
self.content = self.system.render_template('seq_module.html', params)
self.rendered = True
示例8: render
# 需要导入模块: from xmodule.progress import Progress [as 别名]
# 或者: from xmodule.progress.Progress import to_js_status_str [as 别名]
def render(self):
# If we're rendering this sequence, but no position is set yet,
# default the position to the first element
if self.position is None:
self.position = 1
if self.rendered:
return
## Returns a set of all types of all sub-children
contents = []
for child in self.get_display_items():
progress = child.get_progress()
childinfo = {
"content": child.get_html(),
"title": "\n".join(
grand_child.display_name
for grand_child in child.get_children()
if grand_child.display_name is not None
),
"progress_status": Progress.to_js_status_str(progress),
"progress_detail": Progress.to_js_detail_str(progress),
"type": child.get_icon_class(),
"id": child.id,
}
if childinfo["title"] == "":
childinfo["title"] = child.display_name_with_default
contents.append(childinfo)
params = {
"items": contents,
"element_id": self.location.html_id(),
"item_id": self.id,
"position": self.position,
"tag": self.location.category,
}
self.content = self.system.render_template("seq_module.html", params)
self.rendered = True