#!/usr/bin/python
#
# File:  mitx/lib/loncapa/loncapa_check.py
#
# 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):
    '''
    like random.randrange but lower and upper can be non-integer
    '''
    nstep = int((upper-lower)/(1.0*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



@@ -843,21 +843,21 @@
 d = 
-180.0*
 math.pi
+/180.0
 %0Arad
@@ -867,20 +867,17 @@
 g = 
-math.pi * 180
+180.0/math
 %0A%0A%0A

fix bug in loncapa_check