MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / part_to_child

Function part_to_child

pythonwhat/checks/check_funcs.py:16–42  ·  view source on GitHub ↗
(stu_part, sol_part, append_message, state, node_name=None)

Source from the content-addressed store, hash-verified

14
15
16def part_to_child(stu_part, sol_part, append_message, state, node_name=None):
17 # stu_part and sol_part will be accessible on all templates
18 append_message.kwargs.update({"stu_part": stu_part, "sol_part": sol_part})
19
20 # if the parts are dictionaries, use to deck out child state
21 if all(isinstance(p, dict) for p in [stu_part, sol_part]):
22 child_state = state.to_child(
23 student_ast=stu_part["node"],
24 solution_ast=sol_part["node"],
25 student_context=stu_part.get("target_vars"),
26 solution_context=sol_part.get("target_vars"),
27 student_parts=stu_part,
28 solution_parts=sol_part,
29 highlight=stu_part.get("highlight"),
30 append_message=append_message,
31 node_name=node_name,
32 )
33 else:
34 # otherwise, assume they are just nodes
35 child_state = state.to_child(
36 student_ast=stu_part,
37 solution_ast=sol_part,
38 append_message=append_message,
39 node_name=node_name,
40 )
41
42 return child_state
43
44
45def check_part(state, name, part_msg, missing_msg=None, expand_msg=None):

Callers 7

check_functionFunction · 0.90
check_objectFunction · 0.90
check_keysFunction · 0.90
check_partFunction · 0.85
check_part_indexFunction · 0.85
check_nodeFunction · 0.85
check_callFunction · 0.85

Calls 2

updateMethod · 0.80
to_childMethod · 0.80

Tested by

no test coverage detected