---
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 showanswer="closed" rerandomize="never" weight="10" display_name="lec1_Q2">
      <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.org/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>
        <fieldset>
          <legend>Which of the following countries celebrates its independence on August 15?</legend>
          <br/>
          <optionresponse>
            <optioninput options="('India','Spain','China','Bermuda')" correct="India"></optioninput>
          </optionresponse>
        </fieldset>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>India became an independent nation on August 15, 1947.</p>
          </div>
        </solution>
        <br/>
        <p><strong>Example Multiple Choice Problem</strong></p>
        <fieldset>
          <legend>Which of the following countries has the largest population?</legend>
          <multiplechoiceresponse>
            <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>
          </multiplechoiceresponse>
        </fieldset>
        <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>
        <br/>
        <p><strong>Example Math Expression Problem</strong></p>
        <fieldset>
          <legend>What is Einstein's equation for the energy equivalent of a mass [mathjaxinline]m[/mathjaxinline]?</legend>
          <symbolicresponse expect="m*c^2">
            <textline size="90" correct_answer="m*c^2" math="1"/>
          </symbolicresponse>
        </fieldset>
        <br/>
        <p><strong>Example Numerical Problem</strong></p>
        <fieldset>
          <legend>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.</legend>
          <p style="display:inline">Energy saved = </p>
          <numericalresponse inline="1" answer="0.52">
            <textline inline="1">
              <responseparam type="tolerance" default="0.02"/>
            </textline>
            <p style="display:inline">&#xA0;EJ/year</p>
          </numericalresponse>
        </fieldset>
        <br/>
        <p><strong>Example Fill-in-the-Blank Problem</strong></p>
        <fieldset>
          <legend>What was the first post-secondary school in China to allow both male and female students?</legend>
          <stringresponse answer="Nanjing Higher Normal Institute" type="ci" >
            <additional_answer>National Central University</additional_answer>
            <additional_answer>Nanjing University</additional_answer>
            <textline label="What was the first post-secondary school in China to allow both male and female students?" size="40"/>
          </stringresponse>
        </fieldset>
        <solution>
          <div class="detailed-solution">
            <p>Explanation</p>
            <p>Nanjing Higher Normal Institute first admitted female students in 1920.</p>
          </div>
        </solution>
       <br/>
       <p><strong>Example Custom Python-Evaluated Input Problem</strong></p>
        <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

    def test_add_to_ten(expect, ans):
        return test_add(10, ans)
      </script>
      <fieldset>
        <legend>Enter two integers that sum to 10.</legend>
        <customresponse cfn="test_add_to_ten">
          <textline size="40" correct_answer="3" label="Integer #1"/><br/>
          <textline size="40" correct_answer="7" label="Integer #2"/>
        </customresponse>
      </fieldset>
      <fieldset>
        <legend>Enter two integers that sum to 20.</legend>
        <customresponse cfn="test_add" expect="20">
          <textline size="40" correct_answer="11" label="Integer #1"/><br/>
          <textline size="40" correct_answer="9" label="Integer #2"/>
        </customresponse>
      </fieldset>
      <solution>
        <div class="detailed-solution">
          <p>Explanation</p>
          <p>Any set of integers on the line \(y = 10 - x\) and \(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>
      <br/>
      <p><strong>Example Image Mapped Input Problem</strong></p>
        <fieldset>
          <legend>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.</legend>
          <imageresponse>
           <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"/>
          </imageresponse>
        </fieldset>
        <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>
        <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>