restart: with(Maplets[Tools]): with(Maplets[Elements]): with(plots): StartEngine(); randomize(): FindSlope:=Maplet(onstartup = RunWindow(MAIN), Window[MAIN](title="Slopes of Lines", [ [ Button("Ask Question", Evaluate(function = "ask"), background=magenta), HorizontalGlue(), Button("Quit", Shutdown(), background=pink) ], [ TextField[question](width=40, editable=false, background=white) ], [ "Answer: ", TextField[answer](width=25), [ Button("Check Answer", Evaluate(function = "check"), background=green), Button("Show Answer", Evaluate(function = "show"), background=yellow) ] ], [ TextField[reply](width=40, editable=false, background=white) ] ] ) ): ask:=proc() global correctslope; local a,b,c,d, rand5; rand5:=rand(-5..5): a:=rand5(); b:=rand5(); c:=rand5(); d:=rand5(); while a=c do c:=rand5(); end do; correctslope:=(d-b)/(c-a); Set(question=sprintf( "Find the slope of the line through the points (%a,%a) and (%a,%a).", a,b,c,d )) end proc: check:=proc() global correctslope; local userslope; userslope:=Get(answer::realcons, corrections=true, update=true): if userslope=correctslope then Set(reply="Correct! Try another question.") else Set(reply="Incorrect. Try again.") end if; end proc: show:=proc() global correctslope; Set(answer=correctslope): Set(reply="Next time try doing it yourself."); end proc: Maplets[Display]( FindSlope );