---
metadata:
    display_name: Problem Written in LaTeX
    source_code: |
        % Nearly any kind of edX problem can be authored using LaTeX as
        % the source language.  Write LaTeX as usual, including equations. The
        % key feature is the \edXabox{} macro, which specifies an "answer
        % box" that queries students for a response, and specifies what the
        % expected (correct) answer is.

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "option" problem}

        Which of the following countries celebrates its independence on August 15?

        \edXabox{options='India','Spain','China','Bermuda' expect='India'}

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "multiple choice" problem}

        Which of the following countries has the largest population?

        \edXabox{ type="multichoice" expect="Indonesia" options="Brazil","Germany","Indonesia","Russia" }

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "symbolic" problem}

        What is Einstein's equation for the energy equivalent of a mass $m$?

        \edXabox{type='symbolic' size='90' expect='m*c^2' }

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "numerical" problem}

        Estimate the energy savings (in J/y) if all the people
        ($3\times 10^8$) in the U.~S. switched from U.~S. code to low-flow
        shower heads.

        \edXinline{Energy saved = }\edXabox{expect="0.52" type="numerical" tolerance='0.02' inline='1' } %
        \edXinline{~EJ/year}

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "string response" problem}

        What was the first post-secondary school in China to allow both male and female students?

        \edXabox{ type="string" expect="Nanjing Higher Normal Institute" options="ci" }

        You can include an explanation of the answer by using the edXsolution
        macro. Click "Show Answer" to see the explanation.

        \begin{edXsolution}
        Nanjing Higher Normal Institute first admitted female students in 1920.
        \end{edXsolution}

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example "custom response" problem}

        In this problem, a custom Python script determines if the answer is correct.

        \begin{edXscript}
        def sumtest(expect,ans):
            (a1,a2) = map(float,eval(ans))
            return (a1+a2)==10
        \end{edXscript}

        Enter a Python list of two numbers that sum to 10. For example, your answer might be [9,1] or [4,6].

        \edXabox{expect="[1,9]" type="custom" cfn="sumtest"}

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example image}

        Include an image by using the following macro:

        \edXxml{<img src="https://courses.edx.org/static/images/placeholder-image.png"/>}

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \subsection{Example show/hide explanation}

        You can provide additional information that only appears at certain times by including a "showhide" flag.

        \edXshowhide{sh1}{More explanation}{This is a hidden explanation. It
        can contain equations, such as $\alpha = \frac{2}{\sqrt{1+\gamma}}$ }.

        This is additional text after the hidden explanation.
    markdown: !!null

data: |
    <?xml version="1.0"?>
    <problem>
      <p>
          If you have a problem that is already written in LaTeX, you can use this problem type to
          easily convert your code into XML. After you paste your code into the LaTeX editor,
          you only need to make a few minor adjustments.
      </p>
      <p>
          For more information, see
          <a href="http://edx.readthedocs.io/projects/edx-partner-course-staff/en/latest/exercises_tools/problem_in_latex.html" target="_blank">
          Problem Written in LaTeX</a> in <i>Building and Running an edX Course</i>.
      </p>
      <p>You can use the following example problems as models.</p>
      <p><strong>Example Option Problem</strong></p>
      <br/>
      <optionresponse>
        <label>Which of the following countries celebrates its independence on August 15?</label>
        <optioninput options="('India','Spain','China','Bermuda')" correct="India"></optioninput>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>India became an independent nation on August 15, 1947.</p>
          </div>
        </solution>
      </optionresponse>
      <br/>

      <p><strong>Example Multiple Choice Problem</strong></p>
      <multiplechoiceresponse>
        <label>Which of the following countries has the largest population?</label>
        <choicegroup type="MultipleChoice">
          <choice correct="false" name="brazil">Brazil</choice>
          <choice correct="false" name="germany">Germany</choice>
          <choice correct="true" name="indonesia">Indonesia</choice>
          <choice correct="false" name="russia">Russia</choice>
        </choicegroup>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>According to September 2014 estimates:</p>
            <p>The population of Indonesia is approximately 250 million.</p>
            <p>The population of Brazil  is approximately 200 million.</p>
            <p>The population of Russia is approximately 146 million.</p>
            <p>The population of Germany is approximately 81 million.</p>
          </div>
        </solution>
      </multiplechoiceresponse>
      <br/>

      <p><strong>Example Math Expression Problem</strong></p>
      <symbolicresponse expect="m*c^2">
        <p>What is Einstein's equation for the energy equivalent of a mass [mathjaxinline]m[/mathjaxinline]?</p>
        <textline size="90" correct_answer="m*c^2" math="1"/>
      </symbolicresponse>
      <br/>

      <p><strong>Example Numerical Problem</strong></p>
      <numericalresponse inline="1" answer="0.52">
        <label>Estimate the energy savings (in J/y) if all the people ([mathjaxinline]3\times 10^8[/mathjaxinline]) in the U.&#xA0;S. switched from U.&#xA0;S. code to low-flow shower heads.</label>
        <formulaequationinput trailing_text="EJ/year" />
        <responseparam type="tolerance" default="0.02"/>
      </numericalresponse>
      <br/>

      <p><strong>Example Fill-in-the-Blank Problem</strong></p>
      <stringresponse answer="Nanjing Higher Normal Institute" type="ci" >
        <label>What was the first post-secondary school in China to allow both male and female students?</label>
        <additional_answer>National Central University</additional_answer>
        <additional_answer>Nanjing University</additional_answer>
        <textline size="40"/>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>Nanjing Higher Normal Institute first admitted female students in 1920.</p>
          </div>
        </solution>
      </stringresponse>
      <br/>

      <p><strong>Example Custom Python-Evaluated Input Problem</strong></p>

      <customresponse cfn="test_add_to_ten">
        <script type="loncapa/python">
    def test_add_to_ten(expect, ans):
        return test_add(10, ans)
      </script>
        <p>Enter two integers that sum to 10.</p>
        <textline size="40" correct_answer="3"/><br/>
        <textline size="40" correct_answer="7"/>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>Any set of integers on the line \(y = 10 - x\) satisfy these constraints.</p>
          </div>
        </solution>
      </customresponse>

      <customresponse cfn="test_add" expect="20">
        <script type="loncapa/python">
    def test_add(expect, ans):
        try:
            a1=int(ans[0])
            a2=int(ans[1])
            return (a1+a2) == int(expect)
        except ValueError:
            return False
      </script>
        <p>Enter two integers that sum to 20.</p>
        <textline size="40" correct_answer="11"/><br/>
        <textline size="40" correct_answer="9"/>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>Any set of integers on the line \(y = 20 - x\) satisfy these constraints.</p>
            <p>To add an image to the solution, use an HTML "img" tag. Make sure to include alt text.</p>
            <img src="/static/images/placeholder-image.png" width="400" alt="Description of image"/>
          </div>
        </solution>
      </customresponse>
      <br/>

      <p><strong>Example Image Mapped Input Problem</strong></p>
      <imageresponse>
        <p>
          What country is home to the Great Pyramid of Giza as well as the cities
          of Cairo and Memphis? Click the country on the map below.
        </p>
        <imageinput src="https://studio.edx.org/c4x/edX/DemoX/asset/Africa.png"
        width="600" height="638" rectangle="(338,98)-(412,168)" alt="Map of
        Africa"/>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>Egypt is home to not only the Pyramids, Cairo, and Memphis, but also
            the Sphinx and the ancient Royal Library of Alexandria.</p>
          </div>
        </solution>
      </imageresponse>
      <br/>

      <p><strong>Example Hidden Explanation</strong></p>
      <p>You can provide additional information that only appears at certain times by including a "showhide" flag. </p>
      <p>
        <table class="wikitable collapsible collapsed">
          <tbody>
            <tr>
              <th> More Information [<a href="javascript:$('#sh1').toggle()" id="sh1l">show</a>]</th>
            </tr>
            <tr id="sh1" style="display:none">
              <td>
                <p>This is a hidden explanation. It can contain equations, such as [mathjaxinline]\alpha = \frac{2}{\sqrt {1+\gamma }}[/mathjaxinline].  </p>
                <p>This is additional text after the hidden explanation. </p>
              </td>
            </tr>
          </tbody>
        </table>
      </p>
    </problem>
