Simple Sample Problem

From WeBWorK_wiki
Revision as of 17:31, 16 June 2021 by Berndsing (talk | contribs) (added tag)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Prep Main Page > Web Conference 1 > Simple Sample Problem

############################################################
# DESCRIPTION
# Very simple sample problem for WeBWorK PREP workshop
# WeBWorK problem written by Gavin LaRose, <glarose@umich.edu>
# ENDDESCRIPTION

DOCUMENT();
loadMacros( "PGstandard.pl", "MathObjects.pl" );

############################################################
# problem set-up
# 
Context("Numeric");
$a = random(2,8,1);
$f = Compute( "x^$a" );

############################################################
# text
#
TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT
Find the derivative of \(f(x) = $f\):
$BR
\( f'(x) = \) \{ $f->ans_rule(10) \}
END_TEXT
Context()->normalStrings;

############################################################
# answer and solution
#
$fp = $f->D()
ANS( $fp->cmp() );

Context()->texStrings;
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR
\( f'(x) = $fp \), by the power rule.
END_SOLUTION
Context()->normalStrings;

ENDDOCUMENT();