Difference between revisions of "DraggableProofs"

From WeBWorK_wiki
Jump to navigation Jump to search
(Updates to the draggableproof macro which is now in PG.)
 
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>
   

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