I think your second solution will work quite well!
I have two followups:
- Is it possible to create an ANS without an ans_box? At the moment I have a very hacky solution: I have NAMED_ANS("_answer", String("x")->cmp->withPostFilter(...)). I use the values stored from $input_ref's to make a custom answer checker, and I use JavaScript to autofill the "_answer" input with "x" so it always passes the parse test. Ideally, there would be no parse test and the <input id="_answer"> would be empty, or it would not exist at all.
- How can I tell webwork inside of withPostFilter that a particular answer should not deduct from a student's number of attempts. Is this possible?