<problem display_name="Drag and drop demos chem features: drag and drop icons or labels
    to proper positions." attempts="10">

<customresponse>
    <text>
        <h4>[Simple grading example: draggables on draggables]</h4><br/>
        <h4>Describe carbon molecule in LCAO-MO.</h4><br/>
        <br/>
    </text>

    <drag_and_drop_input img="/static/images/images_list/lcao-mo/lcao-mo.jpg" target_outline="true" >

        <!-- filled bond -->
        <draggable id="up_and_down" icon="/static/images/images_list/lcao-mo/u_d.png" can_reuse="true" />
        <!-- up bond -->
        <draggable id="up"  icon="/static/images/images_list/lcao-mo/up.png" can_reuse="true" />

        <draggable id="s" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="s orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p" icon="/static/images/images_list/lcao-mo/orbital_triple.png" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
            <target id="2" x="34" y="0" w="32" h="32"/>
            <target id="3" x="68" y="0" w="32" h="32"/>
        </draggable>

        <!-- positions of electrons and electron pairs -->
        <target id="s_l" x="130" y="360" w="32" h="32"/>
        <target id="s_r" x="505" y="360" w="32" h="32"/>
        <target id="p_l" x="80"  y="100" w="100" h="32"/>
        <target id="p_r" x="465" y="100" w="100" h="32"/>

  </drag_and_drop_input>

    <answer type="loncapa/python"><![CDATA[
correct_answer = [
    {
        'draggables': ['p'],
        'targets': ['p_l', 'p_r'],
        'rule': 'unordered_equal'
    },
    {
        'draggables': ['s'],
        'targets': ['s_l', 's_r'],
        'rule': 'unordered_equal'
    },
    {
      'draggables': ['up_and_down'],
      'targets': [
        's_l[s][1]', 's_r[s][1]'
      ],
      'rule': 'unordered_equal'
    },
    {
      'draggables': ['up'],
      'targets': [
        'p_l[p][1]', 'p_l[p][3]', 'p_r[p][1]', 'p_r[p][3]'
      ],
      'rule': 'unordered_equal'
    }
]

if draganddrop.grade(submission[0], correct_answer):
    correct = ['correct']
else:
    correct = ['incorrect']
]]></answer>
</customresponse>

<customresponse>
    <text>
        <h4>[Complex grading example: draggables on draggables]</h4><br/>
        <h4>Describe carbon molecule in LCAO-MO.</h4>
        <br/>
    </text>

    <drag_and_drop_input img="/static/images/images_list/lcao-mo/lcao-mo-clean.jpg" target_outline="true" >

        <!-- filled bond -->
        <draggable id="up_and_down" icon="/static/images/images_list/lcao-mo/u_d.png" can_reuse="true" />
        <!-- up bond -->
        <draggable id="up" icon="/static/images/images_list/lcao-mo/up.png" can_reuse="true" />

        <!-- images that should not be dragged -->
        <draggable id="down" icon="/static/images/images_list/lcao-mo/d.png" can_reuse="true" />

        <draggable id="s" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="s orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p" icon="/static/images/images_list/lcao-mo/orbital_triple.png" can_reuse="true" label="p orbital" >
            <target id="1" x="0" y="0" w="32" h="32"/>
            <target id="2" x="34" y="0" w="32" h="32"/>
            <target id="3" x="68" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="s-sigma" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="s-sigma orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="s-sigma*" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="s-sigma* orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p-pi" icon="/static/images/images_list/lcao-mo/orbital_double.png" label="p-pi orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
            <target id="2" x="34" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p-sigma" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="p-sigma orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p-pi*" icon="/static/images/images_list/lcao-mo/orbital_double.png" label="p-pi* orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
            <target id="2" x="34" y="0" w="32" h="32"/>
        </draggable>

        <draggable id="p-sigma*" icon="/static/images/images_list/lcao-mo/orbital_single.png" label="p-sigma* orbital" can_reuse="true" >
            <target id="1" x="0" y="0" w="32" h="32"/>
        </draggable>

        <!-- positions of electrons and electron pairs -->
        <target id="s-left-target" x="130" y="360" w="32" h="32"/>
        <target id="s-right-target" x="505" y="360" w="32" h="32"/>
        <target id="s-sigma-target" x="315" y="425" w="32" h="32"/>
        <target id="s-sigma*-target" x="315" y="290" w="32" h="32"/>
        <target id="p-left-target" x="80"  y="100" w="100" h="32"/>
        <target id="p-right-target" x="480" y="100" w="100" h="32"/>
        <target id="p-pi-target" x="300" y="220" w="66" h="32"/>
        <target id="p-sigma-target" x="315" y="170" w="32" h="32"/>
        <target id="p-pi*-target" x="300" y="40" w="66" h="32"/>
        <target id="p-sigma*-target" x="315" y="0" w="32" h="32"/>

    </drag_and_drop_input>

    <answer type="loncapa/python"><![CDATA[
correct_answer = [
{'draggables': ['p'], 'targets': ['p-left-target', 'p-right-target'], 'rule': 'unordered_equal'},
{'draggables': ['s'], 'targets': ['s-left-target', 's-right-target'], 'rule': 'unordered_equal'},
{'draggables': ['s-sigma'], 'targets': ['s-sigma-target'], 'rule': 'exact'},
{'draggables': ['s-sigma*'], 'targets': ['s-sigma*-target'], 'rule': 'exact'},
{'draggables': ['p-pi'], 'targets': ['p-pi-target'], 'rule': 'exact'},
{'draggables': ['p-sigma'], 'targets': ['p-sigma-target'], 'rule': 'exact'},
{'draggables': ['p-pi*'], 'targets': ['p-pi*-target'], 'rule': 'exact'},
{'draggables': ['p-sigma*'], 'targets': ['p-sigma*-target'], 'rule': 'exact'},
{
    'draggables': ['up_and_down'],
    'targets': ['s-left-target[s][1]', 's-right-target[s][1]', 's-sigma-target[s-sigma][1]', 's-sigma*-target[s-sigma*][1]', 'p-pi-target[p-pi][1]', 'p-pi-target[p-pi][2]'],
    'rule': 'unordered_equal'
},
{
    'draggables': ['up'],
    'targets': ['p-left-target[p][1]', 'p-left-target[p][2]', 'p-right-target[p][2]', 'p-right-target[p][3]',],
    'rule': 'unordered_equal'
}
]

if draganddrop.grade(submission[0], correct_answer):
    correct = ['correct']
else:
    correct = ['incorrect']
]]></answer>
</customresponse>

<customresponse>
    <text>
        <h4>[Complex grading example: no draggables on draggables]</h4><br/>
        <h4>Describe carbon molecule in LCAO-MO.</h4>
        <br/>
    </text>

    <drag_and_drop_input img="/static/images/images_list/lcao-mo/lcao-mo.jpg" target_outline="true">

        <!-- filled bond -->
        <draggable id="1" icon="/static/images/images_list/lcao-mo/u_d.png" can_reuse="true" />

        <!-- up bond -->
        <draggable id="7"  icon="/static/images/images_list/lcao-mo/up.png" can_reuse="true" />

        <!-- sigma -->
        <draggable id="11" icon="/static/images/images_list/lcao-mo/sigma.png" can_reuse="true" />

        <!-- sigma* -->
        <draggable id="13" icon="/static/images/images_list/lcao-mo/sigma_s.png" can_reuse="true" />

        <!-- pi -->
        <draggable id="15" icon="/static/images/images_list/lcao-mo/pi.png" can_reuse="true" />

        <!-- pi* -->
        <draggable id="16" icon="/static/images/images_list/lcao-mo/pi_s.png" can_reuse="true" />

        <!-- images that should not be dragged -->
        <draggable id="17" icon="/static/images/images_list/lcao-mo/d.png" can_reuse="true" />

        <!-- positions of electrons and electron pairs -->
        <target id="s_left"       x="130" y="360"    w="32" h="32"/>
        <target id="s_right"      x="505" y="360"    w="32" h="32"/>
        <target id="s_sigma"      x="320" y="425"    w="32" h="32"/>
        <target id="s_sigma_star" x="320" y="290"    w="32" h="32"/>
        <target id="p_left_1"     x="80"  y="100"    w="32" h="32"/>
        <target id="p_left_2"     x="125" y="100"    w="32" h="32"/>
        <target id="p_left_3"     x="175" y="100"    w="32" h="32"/>
        <target id="p_right_1"    x="465" y="100"    w="32" h="32"/>
        <target id="p_right_2"    x="515" y="100"    w="32" h="32"/>
        <target id="p_right_3"    x="560" y="100"    w="32" h="32"/>
        <target id="p_pi_1"       x="290" y="220"    w="32" h="32"/>
        <target id="p_pi_2"       x="335" y="220"    w="32" h="32"/>
        <target id="p_sigma"      x="315" y="170"    w="32" h="32"/>
        <target id="p_pi_star_1"  x="290" y="40"     w="32" h="32"/>
        <target id="p_pi_star_2"  x="340" y="40"     w="32" h="32"/>
        <target id="p_sigma_star" x="315" y="0"      w="32" h="32"/>

        <!-- positions of names of energy levels -->
        <target id="s_sigma_name"      x="400" y="425"  w="32" h="32"/>
        <target id="s_sigma_star_name" x="400" y="290"  w="32" h="32"/>
        <target id="p_pi_name"         x="400" y="220"  w="32" h="32"/>
        <target id="p_sigma_name"      x="400" y="170"  w="32" h="32"/>
        <target id="p_pi_star_name"    x="400" y="40"   w="32" h="32"/>
        <target id="p_sigma_star_name" x="400" y="0"    w="32" h="32"/>

  </drag_and_drop_input>

    <answer type="loncapa/python"><![CDATA[
correct_answer = [
{
  'draggables': ['1'],
  'targets': [
    's_left', 's_right', 's_sigma', 's_sigma_star', 'p_pi_1', 'p_pi_2'
  ],
  'rule': 'exact'
}, {
  'draggables': ['7'],
  'targets': ['p_left_1', 'p_left_2', 'p_right_2','p_right_3'],
  'rule': 'exact'
}, {
  'draggables': ['11'],
  'targets': ['s_sigma_name', 'p_sigma_name'],
  'rule': 'exact'
}, {
  'draggables': ['13'],
  'targets': ['s_sigma_star_name', 'p_sigma_star_name'],
  'rule': 'exact'
}, {
  'draggables': ['15'],
  'targets': ['p_pi_name'],
  'rule': 'exact'
}, {
  'draggables': ['16'],
  'targets': ['p_pi_star_name'],
  'rule': 'exact'
}]

if draganddrop.grade(submission[0], correct_answer):
    correct = ['correct']
else:
    correct = ['incorrect']
]]></answer>
</customresponse>

</problem>
