Return child state with name part as its ast tree
(state, name, part_msg, missing_msg=None, expand_msg=None)
| 43 | |
| 44 | |
| 45 | def check_part(state, name, part_msg, missing_msg=None, expand_msg=None): |
| 46 | """Return child state with name part as its ast tree""" |
| 47 | |
| 48 | if missing_msg is None: |
| 49 | missing_msg = "Are you sure you defined the {{part}}? " |
| 50 | if expand_msg is None: |
| 51 | expand_msg = "Did you correctly specify the {{part}}? " |
| 52 | |
| 53 | if not part_msg: |
| 54 | part_msg = name |
| 55 | append_message = FeedbackComponent(expand_msg, {"part": part_msg}) |
| 56 | |
| 57 | has_part(state, name, missing_msg, append_message.kwargs) |
| 58 | |
| 59 | stu_part = state.student_parts[name] |
| 60 | sol_part = state.solution_parts[name] |
| 61 | |
| 62 | assert_ast(state, sol_part, append_message.kwargs) |
| 63 | |
| 64 | return part_to_child(stu_part, sol_part, append_message, state) |
| 65 | |
| 66 | |
| 67 | def check_part_index(state, name, index, part_msg, missing_msg=None, expand_msg=None): |