Difference between revisions of "ExtractingCoordinatesFromPoint"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code snippet shows the essential PG code to check student answers that are equations. Note that these are <b>insertions</b>, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.</em> |
||
<em>This wiki page is under construction as of 6/13/08.</em> |
<em>This wiki page is under construction as of 6/13/08.</em> |
||
</p> |
</p> |
Revision as of 15:17, 13 June 2008
Your title here: PG Code Snippet
This wiki page is under construction as of 6/13/08.
PG problem file | Explanation |
---|---|
loadMacros("any macros files that are needed"); |
To do ..(what you are doing)........., we don't have to change the
tagging and documentation section of the problem file.
In the initialization section, we need to include the macros file |
Context( "Point" ); push( @point, Point( random(1,5,1) , random(-5,-1,1) ) ); push( @point, Point( random(5,10,1) , random(6,11,1) ) ); ($d1, $d2) = ($point[0] - $point[1])->value; # $d1 = x1 - x2, $d2 = y1 - y2 # Need to put () around $d1 and $d2 because if $d1 = -6, then -6^2 = -36, not 36, as desired. $length = Compute("sqrt( ($d1)^2+($d2)^2 )"); $mid = ( $point[1] + $point[0] ) / 2; |
We don't use
|
Context()->texStrings; BEGIN_TEXT Consider the two points \( $point[0] \) and \( $point[1] \). The distance between them is:\{ $length->ans_rule() \} $BR The midpoint of the line segment that joins them is:\{ $mid->ans_rule() \} $BR END_TEXT Context()->normalStrings; |
The problem text section of the file is as we'd expect. |
ANS( $length->cmp ); ANS( $mid->cmp ); |
As is the answer. |