Je bent je ingevulde velden bij deze pagina aan het verwijderen. Ben je zeker dat je dit wilt doen?
You are erasing your filled-in fields on this page. Are you sure that is what you want?
Nieuwe Versie BeschikbaarNew Version Available
Er is een update van deze pagina. Als je update naar de meest recente versie, verlies je mogelijk je huidige antwoorden voor deze pagina. Hoe wil je verdergaan ?
There is an updated version of this page. If you update to the most recent version, then your current progress on this page will be erased. Regardless, your record of completion will remain. How would you like to proceed?
This isn’t what I would necessarily call convenient - it is more of a proof of concept
and useful for when it is definitely necessary. Hopefully a more convenient/natural
method will be available in future releases.
1 The problem...
No matter how well randomized a specific problem is (Ok, if it’s randomized well
enough this isn’t quite true, but that is usually pretty tough) , if the student does
enough on a page, they already know what mechanics/techniques are involved for
each problem - since the order of the problems don’t change, just the way it was
generated.
Luckily, since we can make strings in Sage, we can technically randomize the prompt
along with the answer box. This allows us to randomize question order, along with
the questions themselves.
2 Example
Consider the problems below - note how the text matches correctly to the actual
style of problem. Hit the “Try Another” button and see how they randomize, but
move together properly. (Note, only 3 items, so you may need to hit the button a few
times to get an actual different order).
3 The Code
3.1 How the code works
It’s a bit tricky because we can’t call sage code within the latex string formation.
Nonetheless we can build a list of prompt/display/answer components, and then
randomize the elements of that list. It’s important to notice that calling “shuffle” on
the list shuffles the list in place (it doesn’t work to assign a new variable to be
the shuffled result) but it only shuffles it on the outermost layer, so the
elements stay in the [prompt,disp,answer] format, which makes calling them
easier.
3.2 The Code Itself
\begin{sagesilent}
#####Define default Sage variables.
#Default function variables
var(’x,y,z,X,Y,Z,r,R’)
#Default function names
var(’f,g,h,dx,dy,dz,dh,df’)
def RandInt(a,b):
""" Returns a random integer in [‘a‘,‘b‘]. Note that ‘a‘ and ‘b‘ should be integers themselves to avoid unexpected behavior.
"""
return QQ(randint(int(a),int(b)))
# return choice(range(a,b+1))
def NonZeroInt(b,c, avoid = [0]):
""" Returns a random integer in [‘b‘,‘c‘] which is not in ‘av‘.
If ‘av‘ is not specified, defaults to a non-zero integer.
"""
while True:
a = RandInt(b,c)
if a not in avoid:
return a
#### Problem p1
p1ans = (x-RandInt(-5,5))*(x-RandInt(-5,5))
p1disp = expand(p1ans)
#### Problem p2
p2ans = (NonZeroInt(-5,5)*x-RandInt(-5,5))*(NonZeroInt(-5,5)*x-RandInt(-5,5))
p2disp = expand(p2ans)
p1prompt = LatexExpr(r’\text{Factor the following polynomial. } \\
\text{Note that its leading coefficient is one, so you should use the coefficient method. }’)
p2prompt = LatexExpr(r’\text{Factor the following polynomial with the AC-method. }’)
p3prompt = LatexExpr(r’\text{Factor the following polynomial via grouping. }\\
\text{Remember you must factor it completely. }’)