%
% File:   example3.tex
% 

\documentclass[12pt]{article}

\usepackage{edXpsl}	% edX

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{edXcourse}{1.00x}{1.00x Fall 2013}[url_name=2013_Fall]
\begin{edXchapter}{Unit 2}[start="2013-11-22"]
\begin{edXsection}{A second section}[due="2013-11-22"]
\begin{edXproblem}{Example problem with hints}{url_name="p1"}
 
Let $x=3$ and $y=9$.  Give two expressions using $x$ and $y$ which add
up to 10.

\begin{edXscript}

myhints = {0: [ {'symbol': 'L', 'hint': 'Should your answer depend on L?'},
              ],
           1: [ {'range': [4, 9],
                      'hint': 'You are out of range'
                  },
              ],
          }
  
def test10(expect, ans):
    samples = 'x,y,L@3,9,1:3,9,5#10'
    given = '(%s)+(%s)' % (ans[0], ans[1])
    ok = is_formula_equal('10', given, samples=samples)
    return {'ok': ok, 'msg': 'given=%s' % given}

\end{edXscript}

\edXabox{type='custom' 
  size='20' 
  expect='10' 
  prompts="First number: ","Second number: " 
  answers="1","9"
  inline="1"
  cfn='test10'
  hints='myhints'
}

\end{edXproblem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{edXproblem}{Example multiple choice problem with hints}{url_name="p2"}
 
What is the largest city in the world?

\begin{edXscript}
aset = [ 'Chicago',
         'New York',
         'Rome',
         'London',
      ]

(ans1,ans2,ans3,ans4) = aset

myhints = [ {'string': 'choice_1', 'hint': 'Too windy'},
            {'string': 'choice_2', 'hint': 'An american classic'},
            {'string': 'choice_3', 'hint': 'Too old'},
            {'string': 'choice_4', 'hint': 'Too rainy'},
            {'debug': True, 'hint': ''},
          ]
  
\end{edXscript}

\edXabox{type="multichoice"
  expect='\$ans2' 
  options="\$ans1","\$ans2","\$ans3","\$ans4" 
  hints='myhints'
}

\end{edXproblem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{edXsection}
\end{edXchapter}
\end{edXcourse}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}
