Difference between revisions of "TextbookSpecificMessages"

From WeBWorK_wiki
Jump to navigation Jump to search
(add historical tag)
 
(6 intermediate revisions by 2 users 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 11: Line 16:
 
Or you may want to have different messages for different text books.
 
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.
 
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 test book.
+
But you also want your problem to be usable in a course using a different text book.
 
</p>
 
</p>
   
Line 23: Line 28:
 
First you have add a line to the course.conf file which will activate the messages when viewed by
 
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<br>
 
students in the course. Here is the line to add for a make believe textbook<br>
$pg{specialPGEnvironmentVars}{Pizer_Calculus_5th} = 1;<br>
+
<code>$pg{specialPGEnvironmentVars}{Pizer_Calculus_5th} = 1;</code><br>
 
If this line is not present, none of the messages below will appear when the problem is viewed.
 
If this line is not present, none of the messages below will appear when the problem is viewed.
 
</p>
 
</p>
   
 
<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 83: Line 88:
   
   
<p>
 
 
<p>
 
<p>
 
Now we show how to put a message inside of an existing BEGIN_TEXT/END_TEXT block.
 
Now we show how to put a message inside of an existing BEGIN_TEXT/END_TEXT block.
</p>
 
 
</p>
 
</p>
   
Line 103: 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, "}
 
\}
 
\}
in the middle of a BEGIN_TEXT/END_TEXT block.
+
in the middle of a BEGIN${US}TEXT/END${US}TEXT block.
   
 
END_TEXT
 
END_TEXT
Line 113: Line 116:
 
<td style="background-color:#ffffcc;padding:7px;">
 
<td style="background-color:#ffffcc;padding:7px;">
 
<p>
 
<p>
Here we use the <code>\{ \}</code> construction to put the perl if statement inside
+
Here we use the <code>\{ \}</code> construction to put the perl <code>if</code> statement inside
of the BEGIN_TEXT/END_TEXT block. The if statement is the same as above. In this case, you
+
of the BEGIN_TEXT/END_TEXT block. The <code>if</code> statement is the same as above. In this case, you
 
should put the comment explaining how textbook specific messages work outside of the
 
should put the comment explaining how textbook specific messages work outside of the
 
BEGIN_TEXT/END_TEXT block.
 
BEGIN_TEXT/END_TEXT block.

Latest revision as of 14: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