On 7/1/11 10:08 AM, HMark wrote:
Hi,

I'd appreciate a pointer to how to resolve what seems to be a timing/
processing issue, where interact is triggered and is processing only
one event (namely the change in the input_box), and ignores another
(the click on the selector button).
'

See commments below.


Thanks,
              HMark.

On Jun 26, 6:16 pm, HMark<[email protected]>  wrote:
Hi,

in the following simple interact function, the behavior I expect is:
1. user clicks on "New Question" and sees printed:
in new. question = 0  answer= 0
2. user types 100 (as an example) into the input_box, and right after
it clicks on "Check", and SHOULD see printed:
in check. question= 1  answer= 100

What I ACTUALLY get is:
1. user clicks on "New Question" and sees printed:
in new. question = 0  answer= 0
2. user types 100 (as an example) into the input_box, and right after
it clicks on "Check", and sees printed:
in new. question = 1  answer= 100


which seems to indicate that when a user types into the input_box, and
doesn't do anything before clicking on the "Check" selector button,
the "state" of the selector button doesn't change; only the state/
value of the input_box changes (i.e. one change at a time?).

I would expect that when I click on "Check", BOTH the value of the
input_box, AND the state of the selector would change or be recognized
by the system.

Isn't this a bug?


Yes. Sort of. It's a design issue. You are correct about your diagnosis. One way to get around this right now is to add an "auto_update=False" parameter to your function, which will add an "Update" button to your interact. Then all changes are saved until you press "Update" and then all changes are sent to the server.

In fact, I'm very glad you reminded us about your post. Alex Kramer and I are rewriting interact functionality right now, and we just spent the last 30 minutes or so talking about design choices in updating output based on the controls. Your use-case led to us making a small tweak in our design to give you what you want. We're thinking of letting the user do something like:

def _setting(
operation = button(['Reset', 'New Question', 'Check'], update=['user_answer']),
    user_answer = input_box(default = 0, label = 'Your answer:', width
= 25, update=False)
    ):

which would mean that a click on the operation button would also get the user_answer value and send that, whereas just a change to the user_answer control would not send an update.

Unfortunately, this rewrite probably won't be in Sage for at least another month, and probably won't be in for another 6 months maybe (it involves changing a lot of other Sage code to put into Sage). However, we have a simple server that will use this interact functionality, so it will be usable in some context in hopefully the next month.

Thanks,

Jason

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to