maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
138 stars 147 forks source link

Propose get_safe_ops as an alternative to get_ops #1159

Closed LukeLongworth closed 3 months ago

LukeLongworth commented 3 months ago

I like the addition of safe_op to STACK because it's nice to know that you're always dealing with a string. After some awkward troubleshooting, I've just noticed that get_ops calls op instead of safe_op.

I imagine that just swapping op for safe_op would break all sorts of unexpected things, so might I suggest that we add get_safe_ops to assessment.mac? My suggested code is:

get_safe_ops(ex):= setify(flatten(get_safe_ops_helper(ex)))$ get_safe_ops_helper(ex):=if mapatom(ex) then [] else append([safe_op(ex)],maplist(get_safe_ops_helper,args(ex)))$

sangwinc commented 3 months ago

That's an excellent suggestion @LukeLongworth, thanks.