(stu_part, sol_part, append_message, state, node_name=None)
| 14 | |
| 15 | |
| 16 | def 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 | |
| 45 | def check_part(state, name, part_msg, missing_msg=None, expand_msg=None): |
no test coverage detected