Difference between revisions of "TextbookSpecificMessages"

From WeBWorK_wiki
Jump to navigation Jump to search
(add historical tag)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">The technique listed here is not recommended. Either have local version of your problem with textbook information or submit problems to the OPL without any textbook related comments.</p>
  +
  +
 
<h2>Textbook specific messages: PG Code Snippet</h2>
 
<h2>Textbook specific messages: PG Code Snippet</h2>
   
Line 28: Line 33:
   
 
<p>
 
<p>
First we show how to put a message in it's own BEGIN_TEXT/END_TEXT block.
+
First we show how to put a message in its own BEGIN_TEXT/END_TEXT block.
 
</p>
 
</p>
 
<p style="text-align:center;">
 
<p style="text-align:center;">
Line 62: Line 67:
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<td style="background-color:#ffffdd;border:black 1px dashed;">
 
<pre>
 
<pre>
if (defined $envir{'Pizer_Calculus_5th'} and $envir{'Pizer_Calculus_5th'}) {
+
if ($envir{'Pizer_Calculus_5th'}) {
   
 
BEGIN_TEXT
 
BEGIN_TEXT
Line 101: Line 106:
 
$PAR
 
$PAR
 
Here is how to put some text, e.g.
 
Here is how to put some text, e.g.
\{if (defined \$envir{'Pizer_Calculus_5th'} and \$envir{'Pizer_Calculus_5th'}) {
+
\{if ($envir{'Pizer_Calculus_5th'}) {
 
"This is similar to Problems 29 and 31 of Section 5.2 of Calculus 5th ed by Pizer, "}
 
"This is similar to Problems 29 and 31 of Section 5.2 of Calculus 5th ed by Pizer, "}
 
\}
 
\}

Latest revision as of 15:19, 16 July 2023

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.

The technique listed here is not recommended. Either have local version of your problem with textbook information or submit problems to the OPL without any textbook related comments.


Textbook specific messages: PG Code Snippet

This code snippet shows the essential PG code to include textbook specific messages in a problem. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.

You may want to include a message in your problem that tells students to look at a specific textbook. Or you may want to have different messages for different text books. In either case the message(s) are only meaningful to students using the specific textbook. But you also want your problem to be usable in a course using a different text book.

This code snippet explains how to set up a course and write the problem so that if the specific textbook is being used in the course, students will see the message for that textbook but if the textbook is not being used in the course, students will not see the message.

First you have add a line to the course.conf file which will activate the messages when viewed by students in the course. Here is the line to add for a make believe textbook
$pg{specialPGEnvironmentVars}{Pizer_Calculus_5th} = 1;
If this line is not present, none of the messages below will appear when the problem is viewed.

First we show how to put a message in its own BEGIN_TEXT/END_TEXT block.

Problem Techniques Index

PG problem file Explanation
# The message below is only meaningful if you 
# are using the textbook "Calculus 5th ed" by Pizer.
# If you are using this textbook, put the following
# line (without the #) in the course.conf file:
# $pg{specialPGEnvironmentVars}{Pizer_Calculus_5th} = 1;
# Then your students will see the message but others,
# not using this text (and not having the above line
# in their course's course.conf file), can still use 
# this problem and their students will not see the message.

We add a comment to the code of the problem explaining how textbook specific messages work.

if ($envir{'Pizer_Calculus_5th'}) {

BEGIN_TEXT
This is similar to Problems 29 and 31 of Section 5.2 of Calculus 5th ed by Pizer.
END_TEXT

};

We check if the enviromental variable 'Pizer_Calculus_5th' is defined and true, and if so we out put the message.



Now we show how to put a message inside of an existing BEGIN_TEXT/END_TEXT block.

PG problem file Explanation
BEGIN_TEXT
Let \[ f(x) = \tan^{-1}($b^x) \]
$PAR
\( f'( x ) = \) \{ans_rule(40) \}
$PAR
Here is how to put some text, e.g.  
\{if ($envir{'Pizer_Calculus_5th'}) {
"This is similar to Problems 29 and 31 of Section 5.2 of Calculus 5th ed by Pizer, "}
\}
in the middle of a BEGIN${US}TEXT/END${US}TEXT block.

END_TEXT

Here we use the \{ \} construction to put the perl if statement inside of the BEGIN_TEXT/END_TEXT block. The if statement is the same as above. In this case, you should put the comment explaining how textbook specific messages work outside of the BEGIN_TEXT/END_TEXT block.

Problem Techniques Index