本文整理汇总了Python中xmodule.progress.Progress类的典型用法代码示例。如果您正苦于以下问题:Python Progress类的具体用法?Python Progress怎么用?Python Progress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Progress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_to_js_status
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")
开发者ID:AzizYosofi,项目名称:edx-platform,代码行数:7,代码来源:test_progress.py
示例2: test_add
def test_add(self):
'''Test the Progress.add_counts() method'''
p = Progress(0, 2)
p2 = Progress(1, 3)
p3 = Progress(2, 5)
pNone = None
add = lambda a, b: Progress.add_counts(a, b).frac()
self.assertEqual(add(p, p), (0, 4))
self.assertEqual(add(p, p2), (1, 5))
self.assertEqual(add(p2, p3), (3, 8))
self.assertEqual(add(p2, pNone), p2.frac())
self.assertEqual(add(pNone, p2), p2.frac())
开发者ID:AzizYosofi,项目名称:edx-platform,代码行数:14,代码来源:test_progress.py
示例3: test_add
def test_add(self):
'''Test the Progress.add_counts() method'''
prg1 = Progress(0, 2)
prg2 = Progress(1, 3)
prg3 = Progress(2, 5)
prg_none = None
add = lambda a, b: Progress.add_counts(a, b).frac()
self.assertEqual(add(prg1, prg1), (0, 4))
self.assertEqual(add(prg1, prg2), (1, 5))
self.assertEqual(add(prg2, prg3), (3, 8))
self.assertEqual(add(prg2, prg_none), prg2.frac())
self.assertEqual(add(prg_none, prg2), prg2.frac())
开发者ID:cmscom,项目名称:edx-platform,代码行数:14,代码来源:test_progress.py
示例4: handle_ajax
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)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:35,代码来源:open_ended_module.py
示例5: handle_ajax
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)
开发者ID:NakarinTalikan,项目名称:edx-platform,代码行数:29,代码来源:open_ended_module.py
示例6: handle_ajax
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)
开发者ID:EduPepperPD,项目名称:pepper2013,代码行数:33,代码来源:self_assessment_module.py
示例7: student_view
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
开发者ID:ngocchung75,项目名称:edx-platform,代码行数:44,代码来源:seq_module.py
示例8: student_view
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
开发者ID:SnowGeekOrg,项目名称:edx-platform,代码行数:43,代码来源:seq_module.py
示例9: get_html
def get_html(self):
if self.contents is None:
self.contents = [{
'id': child.id,
'content': child.get_html(),
'direct_term': self.direct_term,
'progress_detail': Progress.to_js_detail_str(self.get_progress())
} for child in self.get_display_items()]
return self.system.render_template('vert_module.html', {
'items': self.contents
})
开发者ID:NikolayStrekalov,项目名称:edx-platform,代码行数:12,代码来源:vertical_module.py
示例10: render
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
开发者ID:NikolayStrekalov,项目名称:edx-platform,代码行数:38,代码来源:seq_module.py
示例11: render
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
开发者ID:navdeepgaur,项目名称:edx-platform,代码行数:38,代码来源:seq_module.py
示例12: student_view
def student_view(self, context):
fragment = Fragment()
contents = []
all_contents = []
for child in self.get_display_items():
rendered_child = child.render('student_view', context)
fragment.add_frag_resources(rendered_child)
show_now = 'true'
try:
problem_now = child.problem_now
if not problem_now:
show_now = 'false'
except AttributeError:
pass
all_contents.append({
'id': child.id,
'content': rendered_child.content,
'father': self.id,
'direct_term': self.direct_term,
'progress_detail': Progress.to_js_detail_str(self.get_progress()),
'type': child.get_icon_class(),
'show_now': show_now,
'problem_time': child.problem_time if child.get_icon_class() == 'problem' else
[{"id": child2.id if child2.get_icon_class() == 'problem' else "video",
"time": child2.problem_time if child2.get_icon_class() == 'problem' and child2.problem_time is not None else "video",
} for child2 in self.get_display_items()]
})
if self.random_problem_count == -1:
contents = all_contents
else:
contents = random.sample(all_contents, self.random_problem_count)
fragment.add_content(self.system.render_template('vert_module.html', {
'items': contents
}))
return fragment
开发者ID:pelikanchik,项目名称:edx-platform,代码行数:40,代码来源:vertical_module.py
示例13: test_frac
def test_frac(self):
p = Progress(1, 2)
(a, b) = p.frac()
self.assertEqual(a, 1)
self.assertEqual(b, 2)
开发者ID:AzizYosofi,项目名称:edx-platform,代码行数:5,代码来源:test_progress.py
示例14: test_frac
def test_frac(self):
prg = Progress(1, 2)
(a_mem, b_mem) = prg.frac()
self.assertEqual(a_mem, 1)
self.assertEqual(b_mem, 2)
开发者ID:cmscom,项目名称:edx-platform,代码行数:5,代码来源:test_progress.py
示例15: elementary_conjunction
def elementary_conjunction(term, section):
error_return = True
if len(term["source_element_id"]) == 0:
return error_return
if len(term["field"]) == 0:
return error_return
if len(term["sign"]) == 0:
return error_return
if len(term["value"]) == 0:
return error_return
unit = get_unit(term["source_element_id"], section)
if not unit:
return error_return
value = 0
term["value"] = int(term["value"])
if unit.get_progress():
progress = unit.get_progress()
if term["field"]=="score_rel":
value = Progress.percent(progress)
if term["field"]=="score_abs":
str_value = Progress.frac(progress)
value = str_value[0]
else:
value = 0
if term["sign"]== "more":
if value > term["value"]:
return True
else:
return False
if term["sign"]== "more-equals":
if value >= term["value"]:
return True
else:
return False
if term["sign"]== "less":
if value < term["value"]:
return True
else:
return False
if term["sign"]== "less-equals":
if value <= term["value"]:
return True
else:
return False
if term["sign"]== "equals":
if value == term["value"]:
return True
else:
return False
return error_return
开发者ID:NikolayStrekalov,项目名称:edx-platform,代码行数:63,代码来源:seq_module.py
注:本文中的xmodule.progress.Progress类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论