本文整理汇总了Python中xmodule.stringify.stringify_children函数的典型用法代码示例。如果您正苦于以下问题:Python stringify_children函数的具体用法?Python stringify_children怎么用?Python stringify_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringify_children函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _parse
def _parse(self, oeparam, prompt, rubric, system):
'''
Parse OpenEndedResponse XML:
self.initial_display
self.payload - dict containing keys --
'grader' : path to grader settings file, 'problem_id' : id of the problem
self.answer - What to display when show answer is clicked
'''
# Note that OpenEndedResponse is agnostic to the specific contents of grader_payload
prompt_string = stringify_children(prompt)
rubric_string = stringify_children(rubric)
self.child_prompt = prompt_string
self.child_rubric = rubric_string
grader_payload = oeparam.find('grader_payload')
grader_payload = grader_payload.text if grader_payload is not None else ''
# Update grader payload with student id. If grader payload not json, error.
try:
parsed_grader_payload = json.loads(grader_payload)
# NOTE: self.system.location is valid because the capa_module
# __init__ adds it (easiest way to get problem location into
# response types)
except TypeError, ValueError:
# This is a dev_facing_error
log.exception(
"Grader payload from external open ended grading server is not a json object! Object: {0}".format(
grader_payload))
开发者ID:avontd2868,项目名称:edx-platform-custom,代码行数:29,代码来源:open_ended_module.py
示例2: setup_response
def setup_response(self, system, location, definition, descriptor):
"""
Sets up the module
@param system: Modulesystem
@param location: location, to let the module know where it is.
@param definition: XML definition of the module.
@param descriptor: SelfAssessmentDescriptor
@return: None
"""
self.child_prompt = stringify_children(self.child_prompt)
self.child_rubric = stringify_children(self.child_rubric)
开发者ID:LukeLu1263,项目名称:edx-platform,代码行数:11,代码来源:self_assessment_module.py
示例3: test_stringify
def test_stringify():
shard = 1
text = 'Hi <div x="foo">there <span>Bruce</span><b>!</b></div>'
html = '''<html a="b" foo="bar">{0}</html>'''.format(text)
xml = etree.fromstring(html)
out = stringify_children(xml)
assert_equals(out, text)
开发者ID:luisvasq,项目名称:edx-platform,代码行数:7,代码来源:test_stringify.py
示例4: definition_from_xml
def definition_from_xml(cls, xml_object, system):
"""
Pull out the data into dictionary.
Args:
xml_object: xml from file.
Returns:
dict
"""
# check for presense of required tags in xml
expected_children_level_0 = ['render', 'configuration']
for child in expected_children_level_0:
if len(xml_object.xpath(child)) != 1:
raise ValueError("Graphical Slider Tool definition must include \
exactly one '{0}' tag".format(child))
expected_children_level_1 = ['functions']
for child in expected_children_level_1:
if len(xml_object.xpath('configuration')[0].xpath(child)) != 1:
raise ValueError("Graphical Slider Tool definition must include \
exactly one '{0}' tag".format(child))
# finished
return {
'data': stringify_children(xml_object)
}, []
开发者ID:6thfdwp,项目名称:edx-platform,代码行数:27,代码来源:gst_module.py
示例5: get_rubric
def get_rubric(self, get):
"""
Gets the results of a given grader via ajax.
Input: AJAX get dictionary
Output: Dictionary to be rendered via ajax that contains the result html.
"""
all_responses = []
loop_up_to_task = self.current_task_number + 1
for i in xrange(0, loop_up_to_task):
all_responses.append(self.get_last_response(i))
rubric_scores = [all_responses[i]['rubric_scores'] for i in xrange(0, len(all_responses)) if
len(all_responses[i]['rubric_scores']) > 0 and all_responses[i]['grader_types'][
0] in HUMAN_GRADER_TYPE.keys()]
grader_types = [all_responses[i]['grader_types'] for i in xrange(0, len(all_responses)) if
len(all_responses[i]['grader_types']) > 0 and all_responses[i]['grader_types'][
0] in HUMAN_GRADER_TYPE.keys()]
feedback_items = [all_responses[i]['feedback_items'] for i in xrange(0, len(all_responses)) if
len(all_responses[i]['feedback_items']) > 0 and all_responses[i]['grader_types'][
0] in HUMAN_GRADER_TYPE.keys()]
rubric_html = self.rubric_renderer.render_combined_rubric(stringify_children(self.static_data['rubric']),
rubric_scores,
grader_types, feedback_items)
response_dict = all_responses[-1]
context = {
'results': rubric_html,
'task_name': 'Scored Rubric',
'class_name': 'combined-rubric-container'
}
html = self.system.render_template('{0}/combined_open_ended_results.html'.format(self.TEMPLATE_DIR), context)
return {'html': html, 'success': True}
开发者ID:2bj,项目名称:edx-platform,代码行数:31,代码来源:combined_open_ended_modulev1.py
示例6: test_stringify_again
def test_stringify_again():
html = r"""<html name="Voltage Source Answer" >A voltage source is non-linear!
<div align="center">
<img src="/static/images/circuits/voltage-source.png"/>
\(V=V_C\)
</div>
But it is <a href="http://mathworld.wolfram.com/AffineFunction.html">affine</a>,
which means linear except for an offset.
</html>
"""
html = """<html>A voltage source is non-linear!
<div align="center">
</div>
But it is <a href="http://mathworld.wolfram.com/AffineFunction.html">affine</a>,
which means linear except for an offset.
</html>
"""
xml = etree.fromstring(html)
out = stringify_children(xml)
print "output:"
print out
# Tracking strange content repeating bug
# Should appear once
assert_equals(out.count("But it is "), 1)
开发者ID:1amongus,项目名称:edx-platform,代码行数:28,代码来源:test_stringify.py
示例7: _parse
def _parse(self, oeparam, prompt, rubric, system):
'''
Parse OpenEndedResponse XML:
self.initial_display
self.payload - dict containing keys --
'grader' : path to grader settings file, 'problem_id' : id of the problem
self.answer - What to display when show answer is clicked
'''
# Note that OpenEndedResponse is agnostic to the specific contents of grader_payload
prompt_string = stringify_children(prompt)
rubric_string = stringify_children(rubric)
self.child_prompt = prompt_string
self.child_rubric = rubric_string
grader_payload = oeparam.find('grader_payload')
grader_payload = grader_payload.text if grader_payload is not None else ''
# Update grader payload with student id. If grader payload not json, error.
try:
parsed_grader_payload = json.loads(grader_payload)
# NOTE: self.system.location is valid because the capa_module
# __init__ adds it (easiest way to get problem location into
# response types)
except (TypeError, ValueError):
# This is a dev_facing_error
log.exception(
"Grader payload from external open ended grading server is not a json object! Object: {0}".format(
grader_payload))
self.initial_display = find_with_default(oeparam, 'initial_display', '')
self.answer = find_with_default(oeparam, 'answer_display', 'No answer given.')
parsed_grader_payload.update({
'location': self.location_string,
'course_id': system.course_id.to_deprecated_string(),
'prompt': prompt_string,
'rubric': rubric_string,
'initial_display': self.initial_display,
'answer': self.answer,
'problem_id': self.display_name,
'skip_basic_checks': self.skip_basic_checks,
'control': json.dumps(self.control),
})
updated_grader_payload = json.dumps(parsed_grader_payload)
self.payload = {'grader_payload': updated_grader_payload}
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:47,代码来源:open_ended_module.py
示例8: definition_from_xml
def definition_from_xml(cls, xml_object, system):
"""Pull out the data into dictionary.
Args:
xml_object: xml from file.
system: `system` object.
Returns:
(definition, children) - tuple
definition - dict:
{
'answers': <List of answers>,
'question': <Question string>
}
"""
# Check for presense of required tags in xml.
if len(xml_object.xpath(cls._child_tag_name)) == 0:
raise ValueError("Poll_question definition must include \
at least one 'answer' tag")
xml_object_copy = deepcopy(xml_object)
answers = []
for element_answer in xml_object_copy.findall(cls._child_tag_name):
answer_id = element_answer.get('id', None)
if answer_id:
answers.append({
'id': answer_id,
'text': stringify_children(element_answer)
})
xml_object_copy.remove(element_answer)
definition = {
'answers': answers,
'question': stringify_children(xml_object_copy)
}
children = []
return (definition, children)
开发者ID:smartdec,项目名称:edx-platform,代码行数:38,代码来源:poll_module.py
示例9: get_rubric
def get_rubric(self, _data):
"""
Gets the results of a given grader via ajax.
Input: AJAX data dictionary
Output: Dictionary to be rendered via ajax that contains the result html.
"""
all_responses = []
success, can_see_rubric, error = self.check_if_student_has_done_needed_grading()
if not can_see_rubric:
return {
'html': self.system.render_template(
'{0}/combined_open_ended_hidden_results.html'.format(self.TEMPLATE_DIR),
{'error': error}),
'success': True,
'hide_reset': True
}
contexts = []
rubric_number = self.current_task_number
if self.ready_to_reset:
rubric_number+=1
response = self.get_last_response(rubric_number)
score_length = len(response['grader_types'])
for z in xrange(score_length):
if response['grader_types'][z] in HUMAN_GRADER_TYPE:
try:
feedback = response['feedback_dicts'][z].get('feedback', '')
except TypeError:
return {'success' : False}
rubric_scores = [[response['rubric_scores'][z]]]
grader_types = [[response['grader_types'][z]]]
feedback_items = [[response['feedback_items'][z]]]
rubric_html = self.rubric_renderer.render_combined_rubric(stringify_children(self.static_data['rubric']),
rubric_scores,
grader_types, feedback_items)
contexts.append({
'result': rubric_html,
'task_name': 'Scored rubric',
'feedback' : feedback
})
context = {
'results': contexts,
}
html = self.system.render_template('{0}/combined_open_ended_results.html'.format(self.TEMPLATE_DIR), context)
return {'html': html, 'success': True, 'hide_reset' : False}
开发者ID:6thfdwp,项目名称:edx-platform,代码行数:46,代码来源:combined_open_ended_modulev1.py
示例10: get_results
def get_results(self, get):
"""
Gets the results of a given grader via ajax.
Input: AJAX get dictionary
Output: Dictionary to be rendered via ajax that contains the result html.
"""
self.update_task_states()
loop_up_to_task = self.current_task_number + 1
all_responses = []
for i in xrange(0, loop_up_to_task):
all_responses.append(self.get_last_response(i))
context_list = []
for ri in all_responses:
for i in xrange(0, len(ri['rubric_scores'])):
feedback = ri['feedback_dicts'][i].get('feedback', '')
rubric_data = self.rubric_renderer.render_rubric(
stringify_children(self.static_data['rubric']),
ri['rubric_scores'][i])
if rubric_data['success']:
rubric_html = rubric_data['html']
else:
rubric_html = ''
context = {
'rubric_html': rubric_html,
'grader_type': ri['grader_type'],
'feedback': feedback,
'grader_id': ri['grader_ids'][i],
'submission_id': ri['submission_ids'][i],
}
context_list.append(context)
feedback_table = self.system.render_template('{0}/open_ended_result_table.html'.format(self.TEMPLATE_DIR), {
'context_list': context_list,
'grader_type_image_dict': GRADER_TYPE_IMAGE_DICT,
'human_grader_types': HUMAN_GRADER_TYPE,
'rows': 50,
'cols': 50,
})
context = {
'results': feedback_table,
'task_name': "Feedback",
'class_name': "result-container",
}
html = self.system.render_template(
'{0}/combined_open_ended_results.html'.format(self.TEMPLATE_DIR), context)
return {'html': html, 'success': True}
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:45,代码来源:combined_open_ended_modulev1.py
示例11: get_results
def get_results(self, get):
"""
Gets the results of a given grader via ajax.
Input: AJAX get dictionary
Output: Dictionary to be rendered via ajax that contains the result html.
"""
self.update_task_states()
loop_up_to_task = self.current_task_number + 1
all_responses = []
for i in xrange(0, loop_up_to_task):
all_responses.append(self.get_last_response(i))
context_list = []
for ri in all_responses:
for i in xrange(0, len(ri["rubric_scores"])):
feedback = ri["feedback_dicts"][i].get("feedback", "")
rubric_data = self.rubric_renderer.render_rubric(
stringify_children(self.static_data["rubric"]), ri["rubric_scores"][i]
)
if rubric_data["success"]:
rubric_html = rubric_data["html"]
else:
rubric_html = ""
context = {
"rubric_html": rubric_html,
"grader_type": ri["grader_type"],
"feedback": feedback,
"grader_id": ri["grader_ids"][i],
"submission_id": ri["submission_ids"][i],
}
context_list.append(context)
feedback_table = self.system.render_template(
"{0}/open_ended_result_table.html".format(self.TEMPLATE_DIR),
{
"context_list": context_list,
"grader_type_image_dict": GRADER_TYPE_IMAGE_DICT,
"human_grader_types": HUMAN_GRADER_TYPE,
"rows": 50,
"cols": 50,
},
)
context = {"results": feedback_table, "task_name": "Feedback", "class_name": "result-container"}
html = self.system.render_template("{0}/combined_open_ended_results.html".format(self.TEMPLATE_DIR), context)
return {"html": html, "success": True}
开发者ID:jrbl,项目名称:edx-platform,代码行数:43,代码来源:combined_open_ended_modulev1.py
示例12: get_rubric
def get_rubric(self, _data):
"""
Gets the results of a given grader via ajax.
Input: AJAX data dictionary
Output: Dictionary to be rendered via ajax that contains the result html.
"""
all_responses = []
success, can_see_rubric, error = self.check_if_student_has_done_needed_grading()
if not can_see_rubric:
return {
"html": self.system.render_template(
"{0}/combined_open_ended_hidden_results.html".format(self.TEMPLATE_DIR), {"error": error}
),
"success": True,
"hide_reset": True,
}
contexts = []
rubric_number = self.current_task_number
if self.ready_to_reset:
rubric_number += 1
response = self.get_last_response(rubric_number)
score_length = len(response["grader_types"])
for z in xrange(score_length):
if response["grader_types"][z] in HUMAN_GRADER_TYPE:
try:
feedback = response["feedback_dicts"][z].get("feedback", "")
except TypeError:
return {"success": False}
rubric_scores = [[response["rubric_scores"][z]]]
grader_types = [[response["grader_types"][z]]]
feedback_items = [[response["feedback_items"][z]]]
rubric_html = self.rubric_renderer.render_combined_rubric(
stringify_children(self.static_data["rubric"]), rubric_scores, grader_types, feedback_items
)
contexts.append({"result": rubric_html, "task_name": "Scored rubric", "feedback": feedback})
context = {"results": contexts}
html = self.system.render_template("{0}/combined_open_ended_results.html".format(self.TEMPLATE_DIR), context)
return {"html": html, "success": True, "hide_reset": False}
开发者ID:EduPepperPDTesting,项目名称:pepper2013-testing,代码行数:40,代码来源:combined_open_ended_modulev1.py
示例13: assert_label
def assert_label(self, xpath=None, aria_label=False):
"""
Verify label is rendered correctly.
Arguments:
xpath (str): xpath expression for label element
aria_label (bool): check aria-label attribute value
"""
labels = [
{
'actual': "You see, but you do not observe. The distinction is clear.",
'expected': "You see, but you do not observe. The distinction is clear.",
},
{
'actual': "I choose to have <mark>faith</mark> because without that, I have <em>nothing</em>.",
'expected': "I choose to have faith because without that, I have nothing.",
}
]
response_data = {
'response_data': {
'descriptions': {},
'label': ''
}
}
self.context.update(response_data)
for label in labels:
self.context['response_data']['label'] = label['actual']
xml = self.render_to_xml(self.context)
if aria_label:
self.assert_has_xpath(xml, "//*[@aria-label='%s']" % label['expected'], self.context)
else:
element_list = xml.xpath(xpath)
self.assertEqual(len(element_list), 1)
self.assertEqual(stringify_children(element_list[0]), label['actual'])
开发者ID:cpennington,项目名称:edx-platform,代码行数:37,代码来源:test_input_templates.py
示例14: assert_description
def assert_description(self, describedby_xpaths):
"""
Verify that descriptions information is correct.
Arguments:
describedby_xpaths (list): list of xpaths to check aria-describedby attribute
"""
xml = self.render_to_xml(self.context)
# Verify that each description <p> tag has correct id, text and order
descriptions = OrderedDict(
(tag.get('id'), stringify_children(tag)) for tag in xml.xpath('//p[@class="question-description"]')
)
self.assertEqual(self.DESCRIPTIONS, descriptions)
# for each xpath verify that description_ids are set correctly
for describedby_xpath in describedby_xpaths:
describedbys = xml.xpath(describedby_xpath)
# aria-describedby attributes must have ids
self.assertTrue(describedbys)
for describedby in describedbys:
self.assertEqual(describedby, self.DESCRIPTION_IDS)
开发者ID:cpennington,项目名称:edx-platform,代码行数:24,代码来源:test_input_templates.py
示例15: parse
def parse(k):
"""Assumes that xml_object has child k"""
return stringify_children(xml_object.xpath(k)[0])
开发者ID:LukeLu1263,项目名称:edx-platform,代码行数:3,代码来源:self_assessment_module.py
示例16: configuration
def configuration(self):
return stringify_children(
html.fromstring(self.data).xpath('configuration')[0]
)
开发者ID:6thfdwp,项目名称:edx-platform,代码行数:4,代码来源:gst_module.py
示例17: parse_task
def parse_task(k):
"""Assumes that xml_object has child k"""
return [stringify_children(xml_object.xpath(k)[i]) for i in xrange(0, len(xml_object.xpath(k)))]
开发者ID:2bj,项目名称:edx-platform,代码行数:3,代码来源:combined_open_ended_modulev1.py
示例18: __init__
def __init__(self, system, location, definition, descriptor,
instance_state=None, shared_state=None, metadata=None, static_data=None, **kwargs):
"""
Definition file should have one or many task blocks, a rubric block, and a prompt block:
Sample file:
<combinedopenended attempts="10000">
<rubric>
Blah blah rubric.
</rubric>
<prompt>
Some prompt.
</prompt>
<task>
<selfassessment>
<hintprompt>
What hint about this problem would you give to someone?
</hintprompt>
<submitmessage>
Save Succcesful. Thanks for participating!
</submitmessage>
</selfassessment>
</task>
<task>
<openended min_score_to_attempt="1" max_score_to_attempt="1">
<openendedparam>
<initial_display>Enter essay here.</initial_display>
<answer_display>This is the answer.</answer_display>
<grader_payload>{"grader_settings" : "ml_grading.conf",
"problem_id" : "6.002x/Welcome/OETest"}</grader_payload>
</openendedparam>
</openended>
</task>
</combinedopenended>
"""
self.instance_state = instance_state
self.display_name = instance_state.get('display_name', "Open Ended")
self.rewrite_content_links = static_data.get('rewrite_content_links', "")
#We need to set the location here so the child modules can use it
system.set('location', location)
self.system = system
#Tells the system which xml definition to load
self.current_task_number = instance_state.get('current_task_number', 0)
#This loads the states of the individual children
self.task_states = instance_state.get('task_states', [])
#Overall state of the combined open ended module
self.state = instance_state.get('state', self.INITIAL)
self.student_attempts = instance_state.get('student_attempts', 0)
self.weight = instance_state.get('weight', 1)
#Allow reset is true if student has failed the criteria to move to the next child task
self.ready_to_reset = instance_state.get('ready_to_reset', False)
self.attempts = self.instance_state.get('attempts', MAX_ATTEMPTS)
self.is_scored = self.instance_state.get('is_graded', IS_SCORED) in TRUE_DICT
self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) in TRUE_DICT
due_date = self.instance_state.get('due', None)
grace_period_string = self.instance_state.get('graceperiod', None)
try:
self.timeinfo = TimeInfo(due_date, grace_period_string)
except Exception:
log.error("Error parsing due date information in location {0}".format(location))
raise
self.display_due_date = self.timeinfo.display_due_date
self.rubric_renderer = CombinedOpenEndedRubric(system, True)
rubric_string = stringify_children(definition['rubric'])
self._max_score = self.rubric_renderer.check_if_rubric_is_parseable(rubric_string, location, MAX_SCORE_ALLOWED)
#Static data is passed to the child modules to render
self.static_data = {
'max_score': self._max_score,
'max_attempts': self.attempts,
'prompt': definition['prompt'],
'rubric': definition['rubric'],
'display_name': self.display_name,
'accept_file_upload': self.accept_file_upload,
'close_date': self.timeinfo.close_date,
's3_interface': self.system.s3_interface,
'skip_basic_checks': self.skip_basic_checks,
}
self.task_xml = definition['task_xml']
self.location = location
self.setup_next_task()
开发者ID:2bj,项目名称:edx-platform,代码行数:93,代码来源:combined_open_ended_modulev1.py
示例19: load_definition
def load_definition(cls, xml_object, system, location, id_generator):
'''Load a descriptor from the specified xml_object:
If there is a filename attribute, load it as a string, and
log a warning if it is not parseable by etree.HTMLParser.
If there is not a filename attribute, the definition is the body
of the xml_object, without the root tag (do not want <html> in the
middle of a page)
Args:
xml_object: an lxml.etree._Element containing the definition to load
system: the modulestore system or runtime which caches data
location: the usage id for the block--used to compute the filename if none in the xml_object
id_generator: used by other impls of this method to generate the usage_id
'''
filename = xml_object.get('filename')
if filename is None:
definition_xml = copy.deepcopy(xml_object)
cls.clean_metadata_from_xml(definition_xml)
return {'data': stringify_children(definition_xml)}, []
else:
# html is special. cls.filename_extension is 'xml', but
# if 'filename' is in the definition, that means to load
# from .html
# 'filename' in html pointers is a relative path
# (not same as 'html/blah.html' when the pointer is in a directory itself)
pointer_path = "{category}/{url_path}".format(
category='html',
url_path=name_to_pathname(location.name)
)
base = path(pointer_path).dirname()
# log.debug("base = {0}, base.dirname={1}, filename={2}".format(base, base.dirname(), filename))
filepath = "{base}/{name}.html".format(base=base, name=filename)
# log.debug("looking for html file for {0} at {1}".format(location, filepath))
# VS[compat]
# TODO (cpennington): If the file doesn't exist at the right path,
# give the class a chance to fix it up. The file will be written out
# again in the correct format. This should go away once the CMS is
# online and has imported all current (fall 2012) courses from xml
if not system.resources_fs.exists(filepath):
candidates = cls.backcompat_paths(filepath)
# log.debug("candidates = {0}".format(candidates))
for candidate in candidates:
if system.resources_fs.exists(candidate):
filepath = candidate
break
try:
with system.resources_fs.open(filepath) as file:
html = file.read().decode('utf-8')
# Log a warning if we can't parse the file, but don't error
if not check_html(html) and len(html) > 0:
msg = "Couldn't parse html in {0}, content = {1}".format(filepath, html)
log.warning(msg)
system.error_tracker("Warning: " + msg)
definition = {'data': html}
# TODO (ichuang): remove this after migration
# for Fall 2012 LMS migration: keep filename (and unmangled filename)
definition['filename'] = [filepath, filename]
return definition, []
except (ResourceNotFoundError) as err:
msg = 'Unable to load file contents at path {0}: {1} '.format(
filepath, err)
# add more info and re-raise
raise Exception(msg), None, sys.exc_info()[2]
开发者ID:JacobWay,项目名称:edx-platform,代码行数:71,代码来源:html_module.py
示例20: __init__
def __init__(
self,
system,
location,
definition,
descriptor,
instance_state=None,
shared_state=None,
metadata=None,
static_data=None,
**kwargs
):
"""
Definition file should have one or many task blocks, a rubric block, and a prompt block. See DEFAULT_DATA in combined_open_ended_module for a sample.
"""
self.instance_state = instance_state
self.display_name = instance_state.get("display_name", "Open Ended")
# We need to set the location here so the child modules can use it
system.set("location", location)
self.system = system
# Tells the system which xml definition to load
self.current_task_number = instance_state.get("current_task_number", 0)
# This loads the states of the individual children
self.task_states = instance_state.get("task_states", [])
# This gets any old task states that have been persisted after the instructor changed the tasks.
self.old_task_states = instance_state.get("old_task_states", [])
# Overall state of the combined open ended module
self.state = instance_state.get("state", self.INITIAL)
self.student_attempts = instance_state.get("student_attempts", 0)
self.weight = instance_state.get("weight", 1)
# Allow reset is true if student has failed the criteria to move to the next child task
self.ready_to_reset = instance_state.get("ready_to_reset", False)
self.max_attempts = instance_state.get("max_attempts", MAX_ATTEMPTS)
self.is_scored = instance_state.get("graded", IS_SCORED) in TRUE_DICT
self.accept_file_upload = instance_state.get("accept_file_upload", ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = instance_state.get("skip_spelling_checks", SKIP_BASIC_CHECKS) in TRUE_DICT
if system.open_ended_grading_interface:
self.peer_gs = PeerGradingService(system.open_ended_grading_interface, system)
else:
self.peer_gs = MockPeerGradingService()
self.required_peer_grading = instance_state.get("required_peer_grading", 3)
self.peer_grader_count = instance_state.get("peer_grader_count", 3)
self.min_to_calibrate = instance_state.get("min_to_calibrate", 3)
self.max_to_calibrate = instance_state.get("max_to_calibrate", 6)
due_date = instance_state.get("due", None)
grace_period_string = instance_state.get("graceperiod", None)
try:
self.timeinfo = TimeInfo(due_date, grace_period_string)
except Exception:
log.error("Error parsing due date information in location {0}".format(location))
raise
self.display_due_date = self.timeinfo.display_due_date
self.rubric_renderer = CombinedOpenEndedRubric(system, True)
rubric_string = stringify_children(definition["rubric"])
self._max_score = self.rubric_renderer.check_if_rubric_is_parseable(rubric_string, location, MAX_SCORE_ALLOWED)
# Static data is passed to the child modules to render
self.static_data = {
"max_score": self._max_score,
"max_attempts": self.max_attempts,
"prompt": definition["prompt"],
"rubric": definition["rubric"],
"display_name": self.display_name,
"accept_file_upload": self.accept_file_upload,
"close_date": self.timeinfo.close_date,
"s3_interface": self.system.s3_interface,
"skip_basic_checks": self.skip_basic_checks,
"control": {
"required_peer_grading": self.required_peer_grading,
"peer_grader_count": self.peer_grader_count,
"min_to_calibrate": self.min_to_calibrate,
"max_to_calibrate": self.max_to_calibrate,
},
}
self.task_xml = definition["task_xml"]
self.location = location
self.fix_invalid_state()
self.setup_next_task()
开发者ID:EduPepperPDTesting,项目名称:pepper2013-testing,代码行数:91,代码来源:combined_open_ended_modulev1.py
注:本文中的xmodule.stringify.stringify_children函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论