Commit 62f17179 by ichuang

add more loncapa check functions (choose, rad2deg, deg2rad)

parent bccdeb2a
......@@ -5,7 +5,9 @@
# Python functions which duplicate the standard comparison functions available to LON-CAPA problems.
# Used in translating LON-CAPA problems to i4x problem specification language.
from __future__ import division
import random
import math
def lc_random(lower,upper,stepsize):
'''
......@@ -15,3 +17,19 @@ def lc_random(lower,upper,stepsize):
choices = [lower+x*stepsize for x in range(nstep)]
return random.choice(choices)
def lc_choose(index,*args):
'''
return args[index]
'''
try:
return args[int(index)-1]
except Exception,err:
pass
if len(args):
return args[0]
raise Exception,"loncapa_check.lc_choose error, index=%s, args=%s" % (index,args)
deg2rad = 180.0*math.pi
rad2deg = math.pi * 180
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment