Difference between revisions of "DomainRange1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Created page with '<h2>Domain and Range of a Function</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> Thi…')
 
(6 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
This PG code shows how to evaluate answers that are inequalities which use different variables.
 
This PG code shows how to evaluate answers that are inequalities which use different variables.
 
</p>
 
</p>
* Download file: [[File:DomainRange1.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DomainRange1.pg FortLewis/Authoring/Templates/Precalc/DomainRange1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Precalc/DomainRange1.pg</code>
+
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/DomainRange1_PGML.pg FortLewis/Authoring/Templates/Precalc/DomainRange1_PGML.pg]
   
 
<br clear="all" />
 
<br clear="all" />
Line 55: Line 55:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
  +
We must load <code>contextInequalities.pl</code>.
 
</p>
 
</p>
 
</td>
 
</td>
Line 70: Line 71:
   
 
Context("Inequalities-Only")->variables->are(x=>"Real");
 
Context("Inequalities-Only")->variables->are(x=>"Real");
  +
Context()->flags->set(formatStudentAnswer=>'parsed');
  +
 
$domain = Compute("x >= 4");
 
$domain = Compute("x >= 4");
 
</pre>
 
</pre>
Line 76: Line 79:
 
<p>
 
<p>
 
<b>Setup 1:</b>
 
<b>Setup 1:</b>
  +
We specify the context in a way that requires students to enter their answer using inequalities and the variable x. If we had used <code>Context("Inequalities")</code> instead, then students would also be able to enter answers using interval notation. For more details, please see [http://webwork.maa.org/pod/pg/macros/contextInequalities.html contextInequalities.pl]
  +
</p>
  +
<p>
  +
We use <code>formatStudentAnswer=>'parsed'</code> and <code>Compute()</code> so that the student's answer are left as fractions rather than reduced to decimals.
 
</p>
 
</p>
 
</td>
 
</td>
Line 129: Line 136:
 
<pre>
 
<pre>
 
Context("Inequalities-Only")->variables->are(y=>"Real");
 
Context("Inequalities-Only")->variables->are(y=>"Real");
  +
Context()->flags->set(formatStudentAnswer=>'parsed');
   
 
$range = Compute("y >= 0");
 
$range = Compute("y >= 0");
Line 136: Line 144:
 
<p>
 
<p>
 
<b>Setup 2:</b>
 
<b>Setup 2:</b>
  +
We must reset the context and the variable so that students must enter the variable y in their answer.
 
</p>
 
</p>
 
</td>
 
</td>
Line 206: Line 215:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Revision as of 17:53, 7 April 2021

Domain and Range of a Function

Click to enlarge

This PG code shows how to evaluate answers that are inequalities which use different variables.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"contextInequalities.pl",
"AnswerFormatHelp.pl",
);

TEXT(beginproblem());

Initialization: We must load contextInequalities.pl.

Context("Numeric");

$f = Compute("sqrt(x-4)");

Context("Inequalities-Only")->variables->are(x=>"Real");
Context()->flags->set(formatStudentAnswer=>'parsed');

$domain = Compute("x >= 4");

Setup 1: We specify the context in a way that requires students to enter their answer using inequalities and the variable x. If we had used Context("Inequalities") instead, then students would also be able to enter answers using interval notation. For more details, please see contextInequalities.pl

We use formatStudentAnswer=>'parsed' and Compute() so that the student's answer are left as fractions rather than reduced to decimals.

Context()->texStrings;
BEGIN_TEXT
Suppose \( f(x) = $f \).  Enter inequalities for the 
domain and range of \( f \).
$BR
$BR
Domain: 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("inequalities") \}
$BR
END_TEXT
Context()->normalStrings;

Main Text 1:

$showPartialCorrectAnswers = 1;

ANS( $domain->cmp() );

Answer Evaluation 1:

Context("Inequalities-Only")->variables->are(y=>"Real");
Context()->flags->set(formatStudentAnswer=>'parsed');

$range  = Compute("y >= 0");

Setup 2: We must reset the context and the variable so that students must enter the variable y in their answer.

Context()->texStrings;
BEGIN_TEXT
Range:$SPACE$SPACE
\{ ans_rule(20) \}
\{ AnswerFormatHelp("inequalities") \}
END_TEXT
Context()->normalStrings;

Main Text 2:

ANS( $range ->cmp() );

Answer Evaluation 2:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area