@@ -63,7 +63,7 @@ def check_part_index(name, index, part_msg,
6363 return part_to_child (stu_part , sol_part , append_message , state )
6464
6565MSG_MISSING = "FMT:The system wants to check the {ordinal} {typestr} you defined but hasn't found it."
66- MSG_PREPEND = "FMT :Check your code in the {child[part]} of the {ordinal } {typestr}. "
66+ MSG_PREPEND = "__JINJA__ :Check your code for the {{ child[' part']+ ' of the' if child['part']} } {typestr}. "
6767def check_node (name , index , typestr , missing_msg = MSG_MISSING , expand_msg = MSG_PREPEND , state = None ):
6868 rep = Reporter .active_reporter
6969 stu_out = getattr (state , 'student_' + name )
@@ -299,11 +299,14 @@ def call(args,
299299 eval_sol , str_sol = run_call (args , state .solution_parts ['node' ], state .solution_process , get_func , ** kwargs )
300300
301301 if (test == 'error' ) ^ isinstance (str_sol , Exception ):
302- _msg_prefix = "Calling %s for arguments %s " % (argstr , args )
303- raise ValueError (_msg_prefix + call_warnings [test ])
302+ _msg = state .build_message ("Calling for arguments {args} resulted in an error (or not an error if testing for one)." ,
303+ dict (args = args ))
304+ raise ValueError (_msg )
304305
305306 if isinstance (eval_sol , ReprFail ):
306- raise ValueError ("Can't get the result of calling %s for arguments %s: %s" % (argstr , args , eval_sol .info ))
307+ _msg = state .build_message ("Can't get the result of calling it for arguments {args}: {eval_sol.info}" ,
308+ dict (args = args , eval_sol = eval_sol ))
309+ raise ValueError (_msg )
307310
308311 # Run for Submission ------------------------------------------------------
309312 eval_stu , str_stu = run_call (args , state .student_parts ['node' ], state .student_process , get_func , ** kwargs )
@@ -325,7 +328,7 @@ def call(args,
325328from pythonwhat .tasks import ReprFail , UndefinedValue
326329from pythonwhat .Test import EqualTest
327330from pythonwhat import utils
328- def has_expr (incorrect_msg ,
331+ def has_expr (incorrect_msg = "Unexpected expression {test}: expected `{sol_eval}`, got `{stu_eval}` with values{extra_env}." ,
329332 error_msg = "Running an expression in the student process caused an issue" ,
330333 undefined_msg = "FMT:Have you defined `{name}` without errors?" ,
331334 extra_env = None ,
@@ -368,7 +371,9 @@ def has_expr(incorrect_msg,
368371 context = state .student_context )
369372
370373 # kwargs ---
371- fmt_kwargs = {'stu_part' : state .student_parts , 'sol_part' : state .solution_parts , 'name' : name }
374+ fmt_kwargs = {'stu_part' : state .student_parts , 'sol_part' : state .solution_parts ,
375+ 'name' : name , 'test' : test ,
376+ 'extra_env' : " " + str (extra_env or "" ), 'context_vals' : context_vals }
372377 fmt_kwargs ['stu_eval' ] = utils .shorten_str (str (eval_stu ))
373378 fmt_kwargs ['sol_eval' ] = utils .shorten_str (str (eval_sol ))
374379
0 commit comments