hello, i'm trying to quiz my students on divisibility rules using a wildcard.
how do i get the answer to calculate whether a randomly generated number is divisible by a specific divisor.
e.g. is the number {n} divisible by 2?
is the mod function available? if so, how does it work in the calculated answer box?
how do i set the correct response based on the calculated answer (T or F)?
i'm using 1.9.2
david benedetto
sausd
Hello David, you can try this:
is the number {n} divisible by {m}?
The formula that you can use is similar to
is_infinite(log(2/(fmod({n},{m}))))
Then, when {n} is divisible by {m} fmod({n},{m})=0 and is_infinite(log(2/(fmod({n},{m}))))=1. Any other case the result is 0.
The correct response is 1 (YES) or 0 (NOT).
You must choose correctly de set of datas (Decimals places = 0)
Sorry but my english is not very good .
Santi
is the number {n} divisible by {m}?
The formula that you can use is similar to
is_infinite(log(2/(fmod({n},{m}))))
Then, when {n} is divisible by {m} fmod({n},{m})=0 and is_infinite(log(2/(fmod({n},{m}))))=1. Any other case the result is 0.
The correct response is 1 (YES) or 0 (NOT).
You must choose correctly de set of datas (Decimals places = 0)
Sorry but my english is not very good .
Santi
thank you.
i finally realized that "is_infinite(log(2/(fmod({n},{m}))))" was the only line in the calculated answer formula line.
i also changed {m} to a constant so i could test their skills with specific divisors.
however, i am getting a division by zero error (below) in the problem even though the problem works perfectly.
Warning: Division by zero in /home/virtualm/public_html/moodle/question/type/calculated/questiontype.php(877) : eval()'d code on line 1
is the number 6088 divisible by 2?
this error shows up only sporatically. if i preview the question several times it doesn't show up each time. i generated 50 problems from 10 to 9999. in the list none of them show any errors and all are working perfectly.
david
i finally realized that "is_infinite(log(2/(fmod({n},{m}))))" was the only line in the calculated answer formula line.
i also changed {m} to a constant so i could test their skills with specific divisors.
however, i am getting a division by zero error (below) in the problem even though the problem works perfectly.
Warning: Division by zero in /home/virtualm/public_html/moodle/question/type/calculated/questiontype.php(877) : eval()'d code on line 1
is the number 6088 divisible by 2?
this error shows up only sporatically. if i preview the question several times it doesn't show up each time. i generated 50 problems from 10 to 9999. in the list none of them show any errors and all are working perfectly.
david
I have done the same tests and obtain the same warning.
If I look further in the code the fmod() function is used although it is not in the list of allowed functions.
I added this to MDL-18141
Pierre
If I look further in the code the fmod() function is used although it is not in the list of allowed functions.
I added this to MDL-18141
Pierre