DraggableProofs

From WeBWorK_wiki
Jump to navigation Jump to search
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