Message Boards Message Boards

1 Reply
5 Total Likes
View groups...
Share this post:

Using FormPage to practice simple math with my kindergartener

Posted 9 years ago

Winter break is nearly over for my daughter, so today I had some fun creating some simple applications to refresh her memory. I am making use of the FormPage function in my code.

In the first example, I deploy a FormPage that generates simple random sums. Note that the first time the Form is loaded, a question is not available, so I have a form element saying that my daughter should type in any number. Questions then follow. My form is public, so feel free to try it, or deploy your own.

In[4]:= CloudDeploy[
  FormPage[FormObject[{"ans", "Sum"} -> "Number", 
    AppearanceRules -> <|"Description" ->  "To begin, type any number.  Then answer the question  below."|>], Module[{res},
      res = 
       If[#ans === Total@ns, Style["Correct", 40, Blue], 
        Style["Wrong:  " <> StringJoin[Riffle[ToString /@ ns, "+"]] <>" = " <> ToString[Total@ns], 40, Red]];
      ns = RandomInteger[{1, 9}, 2];
      CloudSave[ns, CloudObject["numPair"]];
      Rasterize@TableForm@{res, "Next:", Style[StringJoin[Riffle[ToString /@ ns, "+"]], 40, Purple]},
      ns = RandomInteger[{1, 9}, 2];
      CloudSave[ns, CloudObject["numPair"]]; 
      While[#ans === Total@ns, ns = RandomInteger[{1, 9}, 2]]; 
      Style[StringJoin[Riffle[ToString /@ ns, "+"]], 40, GrayLevel[0.2]]]] &] , Permissions -> "Public"]

Out[4]= CloudObject[""]

enter image description here

The second example tests recognition of spoken numbers. Since Speak isn't yet implemented in the WolframCloud, I can only use a Mathematica notebook here. As with the previous example, I'm using FormPage which cannot load in an initial question.

FormPage[FormObject[{"ans", "Number"} -> "Number", 
  AppearanceRules -> <|"Description" -> "To begin, type any number"|>],
    res = If[#ans === num, Speak["Correct"]; 
      Style["Correct", 40, Blue], Speak["Wrong"]; 
      Style["Wrong:  the number was " <> ToString@num, 40, Red]];
    While[#ans === num, num = RandomInteger[{1, 100}]]; 
    Pause[3]; Speak["Ready, " <> ToString@num]; Pause[1]; Speak[num];
    TableForm[{res, Style["\n  Next:\n"], Style["What is this number?", 40, GrayLevel[0.2]]}],
    num = RandomInteger[{1, 100}]; 
    While[#ans === num, num = RandomInteger[{1, 100}]]; 
    Speak["Ready, " <> ToString@num]; Pause[1]; Speak[num]; 
    Style["What number did I say?", 40, GrayLevel[0.2]]]] &] 

Note that there is other weirdness I had to deal with. In a Mathematica notebook, the Form won't re-evaluate when the same input is submitted. So I ensure that the next question has a different answer than the just submitted value.

This was a rather easy and fun way to occupy my daughter for a short time today. I think she'll be ready to go on Monday!

POSTED BY: Chad Knutson

enter image description here - you earned "Featured Contributor" badge, congratulations !

This is a great post and it has been selected for the curated Staff Picks group. Your profile is now distinguished by a "Featured Contributor" badge and displayed on the "Featured Contributor" board.

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract