Added documentation for drag and drop - targets on draggables feature.
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
<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>
|
||||
@@ -83,9 +83,51 @@ the slider.
|
||||
If no targets are provided, then a draggable can be dragged and placed anywhere
|
||||
on the base image.
|
||||
|
||||
correct answer format
|
||||
Targets on draggables
|
||||
---------------------
|
||||
|
||||
Sometimes it is not enough to have targets only on the base image, and all of the
|
||||
draggables on these targets. If a complex problem exists where a draggable must
|
||||
become itself a target (or many targets), then the following extended syntax
|
||||
can be used: ::
|
||||
|
||||
<draggable {attribute list}>
|
||||
<target {attribute list} />
|
||||
<target {attribute list} />
|
||||
<target {attribute list} />
|
||||
...
|
||||
</draggable>
|
||||
|
||||
The attribute list in the tags above ('draggable' and 'target') is the same as for
|
||||
normal 'draggable' and 'target' tags. The only difference is when you will be
|
||||
specifying inner target position coordinates. Using the 'x' and 'y' attributes you
|
||||
are setting the offset of the inner target from the upper-left corner of the
|
||||
parent draggable (that contains the inner target).
|
||||
|
||||
Limitations of targets on draggables
|
||||
------------------------------------
|
||||
|
||||
1.) Currently there is a limitation to the level of nesting of targets.
|
||||
|
||||
Even though you can pile up a large number of draggables on targets that themselves
|
||||
are on draggables, the Drag and Drop instance will be graded only in the case if
|
||||
there is a maximum of two levels of targets. The first level are the "base" targets.
|
||||
They are attached to the base image. The second level are the targets defined on
|
||||
draggables.
|
||||
|
||||
2.) Another limitation is that the target bounds are not checked against
|
||||
other targets.
|
||||
|
||||
For now, it is the responsibility of the person who is constructing the course
|
||||
material to make sure that there is no overlapping of targets. It is also preferable
|
||||
that targets on draggables are smaller than the actual parent draggable. Technically
|
||||
this is not necessary, but from the usability perspective it is desirable.
|
||||
|
||||
Correct answer format
|
||||
---------------------
|
||||
|
||||
(NOTE: For specifying answers for targets on draggables please see next section.)
|
||||
|
||||
There are two correct answer formats: short and long
|
||||
If short from correct answer is mapping of 'draggable_id' to 'target_id'::
|
||||
|
||||
@@ -180,7 +222,7 @@ Rules are: exact, anyof, unordered_equal, anyof+number, unordered_equal+number
|
||||
'rule': 'unordered_equal'
|
||||
}]
|
||||
|
||||
- And sometimes you want to allow drag only two 'b' draggables, in these case you sould use 'anyof+number' of 'unordered_equal+number' rule::
|
||||
- And sometimes you want to allow drag only two 'b' draggables, in these case you should use 'anyof+number' of 'unordered_equal+number' rule::
|
||||
|
||||
correct_answer = [
|
||||
{
|
||||
@@ -204,6 +246,54 @@ for same number of draggables, anyof is equal to unordered_equal
|
||||
|
||||
If we have can_reuse=true, than one must use only long form of correct answer.
|
||||
|
||||
Answer format for targets on draggables
|
||||
---------------------------------------
|
||||
|
||||
As with the cases described above, an answer must provide precise positioning for
|
||||
each draggable (on which targets it must reside). In the case when a draggable must
|
||||
be placed on a target that itself is on a draggable, then the answer must contain
|
||||
the chain of target-draggable-target. It is best to understand this on an example.
|
||||
|
||||
Suppose we have three draggables - 'up', 's', and 'p'. Draggables 's', and 'p' have targets
|
||||
on themselves. More specifically, 'p' has three targets - '1', '2', and '3'. The first
|
||||
requirement is that 's', and 'p' are positioned on specific targets on the base image.
|
||||
The second requirement is that draggable 'up' is positioned on specific targets of
|
||||
draggable 'p'. Below is an excerpt from a problem.::
|
||||
|
||||
<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" 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>
|
||||
|
||||
...
|
||||
|
||||
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': ['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'
|
||||
}
|
||||
]
|
||||
|
||||
Note that it is a requirement to specify rules for all draggables, even if some draggable gets included
|
||||
in more than one chain.
|
||||
|
||||
Grading logic
|
||||
-------------
|
||||
@@ -321,3 +411,8 @@ Draggables can be reused
|
||||
------------------------
|
||||
|
||||
.. literalinclude:: drag-n-drop-demo2.xml
|
||||
|
||||
Examples of targets on draggables
|
||||
------------------------
|
||||
|
||||
.. literalinclude:: drag-n-drop-demo3.xml
|
||||
|
||||
Reference in New Issue
Block a user