IntroToWeBWorKProblems

From WeBWorK_wiki
Revision as of 21:05, 25 May 2011 by Glarose (talk | contribs) (Created page with '==What a WeBWorK Problem Is== A WeBWorK problem consists of two related things: '''database metadata''', that indicate the characteristics of the problem in the WeBWorK problem …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

What a WeBWorK Problem Is

A WeBWorK problem consists of two related things: database metadata, that indicate the characteristics of the problem in the WeBWorK problem set (things like the number of attempts, problem weight, etc.), which exist in the WeBWorK database, and a source file which is a text file that defines what text students see, the solution text for the problem, and the algorithmic definition of the mathematics in the problem.

Database Metadata

Database metadata are defined within WeBWorK, usually through the Set Detail editing page in the Instructor Tools in the WeBWorK interface. These data may also be imported from a set definition file to create the parameters of the set and problems in it en masse.

Source File

The source file for a WeBWorK problem is written using the PG (Problem Generation) language, which is based in the scripting language Perl and allows use of TeX to typeset mathematics in the text that the student sees. A very simple example of the text of a source file for a problem is the following

# 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();

# end of problem
############################################################