Difference between revisions of "DraggableProofs"

From WeBWorK_wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/DraggableProof.html a newer version of this problem]</p>
 
<h2>Using Draggable Statements</h2>
 
<h2>Using Draggable Statements</h2>
   
Line 7: Line 10:
   
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
This PG code shows how to apply a javascript-enabled collection of drag and drop statements.
+
This PG code shows how develop a proof with random statements that need to go in the correct order.
 
</p>
 
</p>
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/DraggableProof_PGML.pg FortLewis/Authoring/Templates/Misc/DraggableProof_PGML.pg]
  +
   
 
<p style="text-align:center;">
 
<p style="text-align:center;">
Line 17: Line 22:
   
 
<tr valign="top">
 
<tr valign="top">
<th> PG problem file </th>
+
<th width="50%"> PG problem file </th>
 
<th> Explanation </th>
 
<th> Explanation </th>
 
</tr>
 
</tr>
Line 29: Line 34:
 
DOCUMENT();
 
DOCUMENT();
 
loadMacros(
 
loadMacros(
"PGstandard.pl",
+
'PGstandard.pl',
"draggableProof.pl",
+
'MathObjects.pl',
  +
'PGML.pl',
  +
'draggableProof.pl',
  +
'PGcourse.pl'
 
);
 
);
   
  +
TEXT(beginproblem());
 
</pre>
 
</pre>
   
Line 38: Line 44:
   
 
<td style="background-color:#ccffcc;padding:7px;">
 
<td style="background-color:#ccffcc;padding:7px;">
<p> The draggableProof.pl macro is not yet part of the standard WeBWorK distribution. You will need to download the macro file [[https://github.com/drjt/pg/blob/feature/SageMacro/macros/sage.pl sage.pl ]] FIX THIS LINK and place it in your local macros directory for this to work.
 
  +
<p>Details of the draggableProof.pl macro can be found in [[https://webwork.maa.org/pod/pg/macros/draggableProof.html the POD]].
 
</p>
 
</p>
 
</td>
 
</td>
 
</tr>
 
</tr>
   
<!-- Create the lists -->
+
<!-- Setup section -->
   
 
<tr valign="top">
 
<tr valign="top">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
TEXT(beginproblem());
 
  +
$statements = [
  +
'Assume \(\sqrt{2}=\frac{a}{b}\) where \(a,b\) are integers, with \(\text{gcd}(a,b)=1\) ',
  +
'\(2 = \frac{a^2}{b^2}\)',
  +
'\(a^2 = 2b^2\)',
  +
'if \(a^2\) is even, then \(a\) must be even',
  +
'Let \(a=2k\) for \(k\) some integer',
  +
'We can then write \( 2 = \frac{4k^2}{b^2}\) or \(b^2 = 2k^2\)',
  +
'Therefore \(b^2\) is even, so \(b\) is also even',
  +
'If \(a\) and \(b\) are both even, then the initial assumption that \(\text{gcd}(a,b)=1\) is contradicted.',
  +
'\(\sqrt{2}\) is therefore not rational.'
  +
];
   
$CorrectProof = DraggableProof([
 
  +
# These are extra statements that are not needed.
"Jason Aubrey",
 
  +
$extra = [
"Someone better than Jason but less than everyone else",
 
  +
'Then \(a\) is odd',
"John Travis"
 
  +
'\(b^2\) cannot be rational.',
],
 
  +
'therefore \(a = 2b\)'
  +
];
   
[
 
  +
$proof = DraggableProof(
"Don't complain about it",
 
  +
$statements,
"\(x^2\)"
 
  +
$extra
],
 
  +
);
 
SourceLabel => "Choose from these",
 
TargetLabel => "Place the people in order of increasing usefulness.",
 
);
 
 
</pre>
 
</pre>
 
</td>
 
</td>
   
<td style="background-color:#ffcccc;padding:7px;">
+
<td style="background-color:#ffffcc;padding:7px;">
Notice the format is:
 
 
<p>
 
<p>
[ list of correct statement in order],
 
  +
The <code>DraggableProof</code> function takes an arrayref of correct statements, followed (optionally) by extra statements. See the POD for more options.
</p>
 
<p>
 
[ list of incorrect statements in order],
 
</p>
 
<p>
 
options
 
 
</p>
 
</p>
 
</td>
 
</td>
Line 82: Line 89:
   
   
<!-- Answer evaluation section -->
+
<!-- Print Problem Statement -->
   
 
<tr valign="top">
 
<tr valign="top">
<td style="background-color:#eeddff;border:black 1px dashed;">
+
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML
   
BEGIN_TEXT
 
  +
[@ $proof->Print @]*
  +
END_PGML
  +
</pre>
  +
</td>
   
Select \{ $CorrectProof->numNeeded \} of the following.
 
  +
<td style="background-color:#ffcccc;padding:7px;">
   
$PAR
 
  +
</td>
\{ $CorrectProof->Print \}
 
  +
</tr>
   
END_TEXT
 
  +
<!-- Answer section -->
Context()->normalStrings;
 
   
# Answer Evaluation
 
  +
<tr valign="top">
  +
<td style="background-color:#eeddff;border:black 1px dashed;">
  +
<pre>
  +
ANS($proof->cmp);
  +
</pre>
  +
<td style="background-color:#eeccff;padding:7px;">
  +
<p>
  +
<b>Answer Evaluation:</b>
  +
</p>
  +
</td>
  +
</tr>
   
ANS($CorrectProof->cmp);
 
   
  +
<!-- Solution section -->
   
  +
<tr valign="top">
  +
<td style="background-color:#ddddff;border:black 1px dashed;">
  +
<pre>
  +
BEGIN_PGML_SOLUTION
  +
Solution explanation goes here.
  +
END_PGML_SOLUTION
  +
  +
COMMENT('Allows integration in either order. Uses PGML.');
 
ENDDOCUMENT();
 
ENDDOCUMENT();
 
</pre>
 
</pre>
</td>
 
 
 
<td style="background-color:#ddddff;padding:7px;">
 
<td style="background-color:#ddddff;padding:7px;">
Notice, $CorrectProof->numNeeded returns the actual number of correct statements provided in the first list from above.
 
  +
<p>
  +
<b>Solution:</b>
  +
</p>
 
</td>
 
</td>
 
</tr>
 
</tr>
  +
 
</table>
 
</table>
   
Line 118: Line 146:
 
</p>
 
</p>
   
[[Category:Applets]]
 
 
[[Category:Sample Problems]]
 
[[Category:Sample Problems]]
 
[[Category:Subject Area Templates]]
 
[[Category:Subject Area Templates]]
Line 130: Line 157:
 
[[Category:Problem Techniques]]
 
[[Category:Problem Techniques]]
   
<!--
 
 
<ul>
 
<ul>
<li>POD documentation: [http://webwork.maa.org/pod/pg_TRUNK/macros/AppletObjects.pl.html AppletObjects.pl.html]</li>
+
<li>POD documentation: [https://webwork.maa.org/pod/pg/macros/draggableProof.html draggableProof.html]</li>
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/AppletObjects.pl?view=log AppletObjects.pl]</li>
 
 
 
</ul>
 
</ul>
-->
 

Latest revision as of 08:08, 28 June 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem

Using Draggable Statements


This PG code shows how develop a proof with random statements that need to go in the correct order.


Problem Techniques Index

PG problem file Explanation
DOCUMENT();
loadMacros(
  'PGstandard.pl',
  'MathObjects.pl',
	'PGML.pl',
  'draggableProof.pl',
  'PGcourse.pl'
);

TEXT(beginproblem());

Details of the draggableProof.pl macro can be found in [the POD].

$statements = [
	'Assume \(\sqrt{2}=\frac{a}{b}\) where \(a,b\) are integers, with \(\text{gcd}(a,b)=1\) ',
	'\(2 = \frac{a^2}{b^2}\)',
	'\(a^2 = 2b^2\)',
	'if \(a^2\) is even, then \(a\) must be even',
	'Let \(a=2k\) for \(k\) some integer',
	'We can then write \( 2 = \frac{4k^2}{b^2}\) or \(b^2 = 2k^2\)',
	'Therefore \(b^2\) is even, so \(b\) is also even',
	'If \(a\) and \(b\) are both even, then the initial assumption that  \(\text{gcd}(a,b)=1\) is contradicted.',
	'\(\sqrt{2}\) is therefore not rational.'
 ];

# These are extra statements that are not needed.
 $extra = [
 'Then \(a\) is odd',
 '\(b^2\) cannot be rational.',
 'therefore \(a = 2b\)'
 ];

 $proof = DraggableProof(
 	$statements,
 	$extra
 );

The DraggableProof function takes an arrayref of correct statements, followed (optionally) by extra statements. See the POD for more options.

BEGIN_PGML

[@ $proof->Print @]*
END_PGML
ANS($proof->cmp);

Answer Evaluation:

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

COMMENT('Allows integration in either order.  Uses PGML.');
ENDDOCUMENT();

Solution:

Templates by Subject Area


Problem Techniques Index