https://webwork.maa.org/mediawiki_new/api.php?action=feedcontributions&user=Dpvc&feedformat=atomWeBWorK_wiki - User contributions [en]2021-05-16T23:55:28ZUser contributionsMediaWiki 1.34.0https://webwork.maa.org/mediawiki_new/index.php?title=WeBWorK_Main_Page&diff=20263WeBWorK Main Page2021-01-04T19:38:35Z<p>Dpvc: Fix typo and number of institutions for Edfinity</p>
<hr />
<div><!-- <p style="background:#FFC; border-bottom:#333; border-top:#333; text-align:center"><br />
'''Looking for the [http://webwork.maa.org/moodle/ WeBWorK Moodle site]?'''<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus or to a server at webwork.maa.org. <br />
</p><br />
</p> -->__NOTOC__<br />
{|width="100%" align="center"|<br />
|-style="vertical-align:top"<br />
|<br />
=WeBWorK Documentation Wiki=<br />
{|width = "100%" align="center"<br />
|style="width: 50%; border-width: 0px; color:darkgreen"|{{projectline| Request Wiki Account | Request Wiki Account | To join the Wiki '''[[Special:RequestAccount|request a Wiki account]]'''. Once your account is approved, you can contribute to the wiki and participate in the forums. If you haven't logged into the wiki in a while you may have to reset your password before you can use the forums. |Wiki.png}}<br />
|}<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus. <br />
</p><br />
<br />
=== What is WeBWorK? ===<br />
<br />
[[File:ExampleWebWorkProblem.png|thumb|300px|left|Example of a WeBWork Problem]] <br />
<br />
<br />
{|width = 50% align="left" |300px|<br />
|WeBWorK is a well-tested homework system for delivering individualized problems over the web. By providing students with immediate feedback as to the correctness of their answers, students can be encouraged to make multiple attempts until they succeed. With individualized problem sets, students can work together but will have to enter their own work to receive credit. <br />
<br />
The instructors are provided with real-time statistics, resulting in lesson plans that can be customized to better serve students. <br />
As of June 2020 there were more than 1300 institutions using WeBWorK and the Open Problem library now has over 35,000 curated and indexed exercises. <br />
The majority of the institutions using this homework system are located in the USA, but many are located in Canada and Mexico, as well as in Europe, Asia, and Africa. <br />
|}<br />
<br />
<div style="width:200px; overflow:auto; float:right; margin-left:10px; margin-right:0; border:1px solid; border-color:#C0C0C0; padding:5px; background:white"><br />
<div style="text-align:center; font-size:125%">'''[https://webwork.maa.org/moodle/mod/forum/view.php?id=130 WeBWorK News]''' [[File:rss.gif | link=https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml]] </div><br />
<div><rss max=2 template=MoodleRSSItem title=none charset=UTF-8 >https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml</rss></div><br />
</div><br />
<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px"|{{projectline| A Gallery of Courses | A Gallery of Courses | Model and sample courses using WeBWorK Assignments|Collection.png}}<br />
|style="width: 33%; border-width: 0px"|{{projectline| Introduction | Introduction to WeBWorK | An [[Introduction | article and video]] summarizing many of the key features and benefits of WeBWorK.| intro_video.png }}<br />
|style="width: 33%; border-width: 0px;"|{{projectline|WeBWorK_Sites|WeBWorK Sites| Map of known WeBWorK Sites|Webworkmap-aug-2012-small.png}}<br />
|}<br />
<br />
==Open Collaborators==<br />
{|width = "100%" align="center"<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| LibreTexts |LibreTexts | Platform for the construction, customization, and dissemination of open educational resources (OER) with some WeBWorK utlization. | LibreTexts_icon.png}}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| PreTeXt |PreTeXt | An uncomplicated XML vocabulary for textbooks that can integrate WeBWorK problems. | PTX-logo.png }}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Hosting WeBWorK courses at Runestone|Runestone| "Democratizing textbooks for the 21st century." An open source platform for interactive textbooks. WeBWorK hosting is available. ([https://www.runestoneinteractive.com/ website])| Runestone-logo-small.png}}<br />
|}<br />
<br />
==Proprietary Collaborators==<br />
{|width = "100%" align="center"<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Edfinity|Edfinity| A modern, hosted, NSF-supported, WeBWorK-compatible homework system trusted by 300+ institutions. ([http://edfinity.com website])| edfinity-logo.png}}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Rederly|Rederly| Provides a WeBWorK-compatible homework system with a modern interface. Hosting and consulting is available | Rederly-logo2.png}}<br />
|}<br />
<br />
== Documentation ==<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| A Community of users | A Community of Users | Forums, events, users, etc. |Echo-ambass-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline|Get WeBWorK | Getting started with WeBWorK | downloading, installing, cloud hosting,etc.|Gartoon-globe-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Instructors | Instructors | Resources for teachers |User-phd-48px.png}}<br />
|-<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Authors | Authors | Want to write some problems? |User-library-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Contribute To WeBWorK | Contribute to WeBWorK | Join this open source community |Echo-infra-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Student Information |Students | Support pages for students using WeBWork |User-student-48px.png}}<br />
|}<br />
== Related WeBWorK support sites ==<br />
* wiki: https://webwork.maa.org/wiki<br />
* demo and overview site: https://demo.webwork.rochester.edu/public<br />
* bugzilla: https://bugs.webwork.maa.org<br />
* request tracker: https://rt.webwork.maa.org<br />
* forums (moodle): https://webwork.maa.org/forums<br />
* blog aggregator (planet): https://webwork.maa.org/planet<br />
* github: https://github.com/openwebwork webwork2, pg and webwork-open-problem-library are the principal repos. <br />
== Support ==<br />
<br />
WeBWorK is partially supported by the [http://www.nsf.gov/div/index.jsp?div=DUE DUE Division] of [http://www.nsf.gov/ NSF].</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=WeBWorK_Main_Page&diff=20226WeBWorK Main Page2020-12-09T17:41:18Z<p>Dpvc: Update Edfinity as requested by Shivram</p>
<hr />
<div><!-- <p style="background:#FFC; border-bottom:#333; border-top:#333; text-align:center"><br />
'''Looking for the [http://webwork.maa.org/moodle/ WeBWorK Moodle site]?'''<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus or to a server at webwork.maa.org. <br />
</p><br />
</p> -->__NOTOC__<br />
{|width="100%" align="center"|<br />
|-style="vertical-align:top"<br />
|<br />
=WeBWorK Documentation Wiki=<br />
{|width = "100%" align="center"<br />
|style="width: 50%; border-width: 0px; color:darkgreen"|{{projectline| Request Wiki Account | Request Wiki Account | To join the Wiki '''[[Special:RequestAccount|request a Wiki account]]'''. Once your account is approved, you can contribute to the wiki and participate in the forums. If you haven't logged into the wiki in a while you may have to reset your password before you can use the forums. |Wiki.png}}<br />
|}<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus. <br />
</p><br />
<br />
=== What is WeBWorK? ===<br />
<br />
[[File:ExampleWebWorkProblem.png|thumb|300px|left|Example of a WeBWork Problem]] <br />
<br />
<br />
{|width = 50% align="left" |300px|<br />
|WeBWorK is a well-tested homework system for delivering individualized problems over the web. By providing students with immediate feedback as to the correctness of their answers, students can be encouraged to make multiple attempts until they succeed. With individualized problem sets, students can work together but will have to enter their own work to receive credit. <br />
<br />
The instructors are provided with real-time statistics, resulting in lesson plans that can be customized to better serve students. <br />
As of June 2020 there were more than 1300 institutions using WeBWorK and the Open Problem library now has over 35,000 curated and indexed exercises. <br />
The majority of the institutions using this homework system are located in the USA, but many are located in Canada and Mexico, as well as in Europe, Asia, and Africa. <br />
|}<br />
<br />
<div style="width:200px; overflow:auto; float:right; margin-left:10px; margin-right:0; border:1px solid; border-color:#C0C0C0; padding:5px; background:white"><br />
<div style="text-align:center; font-size:125%">'''[https://webwork.maa.org/moodle/mod/forum/view.php?id=130 WeBWorK News]''' [[File:rss.gif | link=https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml]] </div><br />
<div><rss max=2 template=MoodleRSSItem title=none charset=UTF-8 >https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml</rss></div><br />
</div><br />
<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px"|{{projectline| A Gallery of Courses | A Gallery of Courses | Model and sample courses using WeBWorK Assignments|Collection.png}}<br />
|style="width: 33%; border-width: 0px"|{{projectline| Introduction | Introduction to WeBWorK | An [[Introduction | article and video]] summarizing many of the key features and benefits of WeBWorK.| intro_video.png }}<br />
|style="width: 33%; border-width: 0px;"|{{projectline|WeBWorK_Sites|WeBWorK Sites| Map of known WeBWorK Sites|Webworkmap-aug-2012-small.png}}<br />
|}<br />
<br />
==Collaborators==<br />
<br />
{|width = "100%" align="center"<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Edfinity|Edfinity| A modern, hosted, NSF-supported, WeBWorK-compatible homework system used at 200+ institutions. ([http://edfinity.com website])| edfinity-logo.png}}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Hosting WeBWorK courses at Runestone|Runestone| "Democratizing textbooks for the 21st century." An open source platform for interactive textbooks. WeBWorK hosting is available. ([https://www.runestoneinteractive.com/ website])| Runestone-logo-small.png}}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| Rederly|Rederly| Provides a WeBWorK-compatible homework system with a modern interface. Hosting and consulting is available | Rederly-logo2.png}}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| PreTeXt |PreTeXt | An uncomplicated XML vocabulary for textbooks that can integrate WeBWorK problems. | PTX-logo.png }}<br />
|style="width: 20%; border-width: 0px; vertical-align:top;"|{{projectline| LibreTexts |LibreTexts | Platform for the construction, customization, and dissemination of open educational resources (OER) with some WeBWorK utlization. | LibreTexts_icon.png}}<br />
|}<br />
<br />
== Documentation ==<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| A Community of users | A Community of Users | Forums, events, users, etc. |Echo-ambass-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline|Get WeBWorK | Getting started with WeBWorK | downloading, installing, cloud hosting,etc.|Gartoon-globe-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Instructors | Instructors | Resources for teachers |User-phd-48px.png}}<br />
|-<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Authors | Authors | Want to write some problems? |User-library-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Contribute To WeBWorK | Contribute to WeBWorK | Join this open source community |Echo-infra-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Student Information |Students | Support pages for students using WeBWork |User-student-48px.png}}<br />
|}<br />
== Related WeBWorK support sites ==<br />
* wiki: https://webwork.maa.org/wiki<br />
* demo and overview site: https://demo.webwork.rochester.edu/public<br />
* bugzilla: https://bugs.webwork.maa.org<br />
* request tracker: https://rt.webwork.maa.org<br />
* forums (moodle): https://webwork.maa.org/forums<br />
* blog aggregator (planet): https://webwork.maa.org/planet<br />
* github: https://github.com/openwebwork webwork2, pg and webwork-open-problem-library are the principal repos. <br />
== Support ==<br />
<br />
WeBWorK is partially supported by the [http://www.nsf.gov/div/index.jsp?div=DUE DUE Division] of [http://www.nsf.gov/ NSF].</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=WeBWorK_Main_Page&diff=19901WeBWorK Main Page2020-07-09T20:58:28Z<p>Dpvc: Update Edfinity entry as per request from Shivram</p>
<hr />
<div><!-- <p style="background:#FFC; border-bottom:#333; border-top:#333; text-align:center"><br />
'''Looking for the [http://webwork.maa.org/moodle/ WeBWorK Moodle site]?'''<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus or to a server at webwork.maa.org. <br />
</p><br />
</p> -->__NOTOC__<br />
{|width="100%" align="center"|<br />
|-style="vertical-align:top"<br />
|<br />
=WeBWorK Documentation Wiki=<br />
{|width = "100%" align="center"<br />
|style="width: 50%; border-width: 0px; color:darkgreen"|{{projectline| Request Wiki Account | Request Wiki Account | To join the Wiki '''[[Special:CreateAccount|request a Wiki account]]'''. Once your account is approved, you can contribute to the wiki and participate in the forums. If you haven't logged into the wiki in a while you may have to reset your password before you can use the forums. |Wiki.png}}<br />
|}<br />
<p style="background:#FCF; border-bottom:#333; border-top:#333; padding:0.5em"><br />
This wiki is for instructors using WeBWorK on-line homework in their courses and for those working on the development of WeBWorK. Students using WeBWorK for their homework should '''''not''''' register on this site (unless they wish to help with writing development software). There is however some additional documentation for students which can be reached via the "Students" link below. The course instructor can give students the URL for their WeBWorK course. Usually this is a path to a server on their campus. <br />
</p><br />
<br />
=== What is WeBWorK? ===<br />
<br />
[[File:ExampleWebWorkProblem.png|thumb|300px|left|Example of a WeBWork Problem]] <br />
<br />
<br />
{|width = 50% align="left" |300px|<br />
|WeBWorK is a well-tested homework system for delivering individualized problems over the web. By providing students with immediate feedback as to the correctness of their answers, students can be encouraged to make multiple attempts until they succeed. With individualized problem sets, students can work together but will have to enter their own work to receive credit. <br />
<br />
The instructors are provided with real-time statistics, resulting in lesson plans that can be customized to better serve students. <br />
As of June 2020 there were more than 1300 institutions using WeBWorK and the Open Problem library now has over 35,000 curated and indexed exercises. <br />
The majority of the institutions using this homework system are located in the USA, but many are located in Canada and Mexico, as well as in Europe, Asia, and Africa. <br />
|}<br />
<br />
<div style="width:200px; overflow:auto; float:right; margin-left:10px; margin-right:0; border:1px solid; border-color:#C0C0C0; padding:5px; background:white"><br />
<div style="text-align:center; font-size:125%">'''[https://webwork.maa.org/moodle/mod/forum/view.php?id=130 WeBWorK News]''' [[File:rss.gif | link=https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml]] </div><br />
<div><rss max=2 template=MoodleRSSItem title=none charset=UTF-8 >https://webwork.maa.org/moodle/rss/file.php/275/c41c70c1a2e9b801e08d5e7fca315d39/mod_forum/31/rss.xml</rss></div><br />
</div><br />
<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px"|{{projectline| A Gallery of Courses | A Gallery of Courses | Model and sample courses using WeBWorK Assignments|Collection.png}}<br />
|style="width: 33%; border-width: 0px"|{{projectline| Introduction | Introduction to WeBWorK | An [[Introduction | article and video]] summarizing many of the key features and benefits of WeBWorK.| intro_video.png }}<br />
|style="width: 33%; border-width: 0px;"|{{projectline|WeBWorK_Sites|WeBWorK Sites| Map of known WeBWorK Sites|Webworkmap-aug-2012-small.png}}<br />
|}<br />
<br />
==Collaborators==<br />
<br />
{|width = "100%" align="center"<br />
|style="width: 25%; border-width: 0px"|{{projectline| Edfinity|Edfinity| A modern, hosted, NSF-Supported, WeBWorK-compatible homework system used at 200+ institutions. ([http://edfinity.com website])| edfinity-logo.png}}<br />
|style="width: 25%; border-width: 0px"|{{projectline| Rederly|Rederly| Provides a WeBWorK-compatible homework system with a modern interface. Hosting and consulting is available | Rederly-logo2.png}}<br />
|style="width: 25%; border-width: 0px"|{{projectline| PreTeXt |PreTeXt | An uncomplicated XML vocabulary for textbooks that can integrate WeBWorK problems. | PTX-logo.png }}<br />
|style="width: 25%; border-width: 0px;"|{{projectline| LibreTexts |LibreTexts | Platform for the construction, customization, and dissemination of open educational resources (OER) with some WeBWorK utlization. | LibreTexts_icon.png}}<br />
|}<br />
<br />
== Documentation ==<br />
{|width = "100%" align="center"<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| A Community of users | A Community of Users | Forums, events, users, etc. |Echo-ambass-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline|Get WeBWorK | Getting started with WeBWorK | downloading, installing, cloud hosting,etc.|Gartoon-globe-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Instructors | Instructors | Resources for teachers |User-phd-48px.png}}<br />
|-<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Authors | Authors | Want to write some problems? |User-library-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Contribute To WeBWorK | Contribute to WeBWorK | Join this open source community |Echo-infra-48px.png}}<br />
|style="width: 33%; border-width: 0px;background-color: #d8e0eb;"|{{projectline| Student Information |Students | Support pages for students using WeBWork |User-student-48px.png}}<br />
|}<br />
== Related WeBWorK support sites ==<br />
* wiki: https://webwork.maa.org/wiki<br />
* demo and overview site: https://demo.webwork.rochester.edu/public<br />
* bugzilla: https://bugs.webwork.maa.org<br />
* request tracker: https://rt.webwork.maa.org<br />
* forums (moodle): https://webwork.maa.org/forums<br />
* blog aggregator (planet): https://webwork.maa.org/planet<br />
* github: https://github.com/openwebwork webwork2, pg and webwork-open-problem-library are the principal repos. <br />
== Support ==<br />
<br />
WeBWorK is partially supported by the [http://www.nsf.gov/div/index.jsp?div=DUE DUE Division] of [http://www.nsf.gov/ NSF].</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Knowls&diff=15750Knowls2018-03-05T09:29:21Z<p>Dpvc: Fix knowlLink() call</p>
<hr />
<div><h2>Knowls</h2><br />
<br />
<!-- Header for these sections -- no modification needed --> <br />
<!--<br />
[[File:GraphicsFilename1.png|300px|thumb|right|Click to enlarge]]<br />
--><br />
<br />
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"><br />
This code fragment shows how to apply a javascript-enabled popup bit of knowledge (a knowl).<br />
</p><br />
<br />
<p style="text-align:center;"><br />
[[IndexOfProblemTechniques|Problem Techniques Index]]<br />
</p><br />
<br />
<table cellspacing="0" cellpadding="2" border="0"><br />
<br />
<tr valign="top"><br />
<th> PG problem file </th><br />
<th> Explanation </th><br />
</tr><br />
<br />
<!-- Load specialized macro files section --><br />
<br />
<!-- Create the lists --><br />
<br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
BEGIN_TEXT<br />
$PAR<br />
Here is a knowl<br />
\{ knowlLink("click me",<br />
value=>'This is the inside of a knowl. ' .<br />
'If you click again, I will go away') \}<br />
<br />
$PAR<br />
Here is another knowl<br />
\{ knowlLink("click me", <br />
url=>'url_of_file_with_information') \}<br />
<br />
$PAR<br />
\{<br />
knowlLink("a math knowl",<br />
escapeSolutionHTML(EV3P("the sine function is \\(\\sin(x)\\)")), base64=>1);<br />
\}<br />
END_TEXT<br />
</pre><br />
</td><br />
<br />
<td style="background-color:#ffcccc;padding:7px;"><br />
<p><br />
Knowls appear in the text section of the problem file. You can specify a value, as in the first example, which gives the text to appear in the Knowl, or the URL of a file with the HTML content for the knowl, as shown in the second example here.<br />
</p><br />
<p><br />
To include math text in the knowl, it is necessary to pipe the text through EV3P and escapeSolution HTML, as shown in the third example.<br />
</p><br />
</td><br />
</tr><br />
<tr valign="top"><br />
<td style="background-color:#ffffdd;border:black 1px dashed;"><br />
<pre><br />
return knowlLink($display_text,<br />
url=>$envir{'localHelpURL'}.$infoRef);<br />
</pre><br />
</td><br />
<td style="background-color:#ffcccc;padding:7px;"><br />
As another example, here is the last line of the definition of helpLink() where the knowl <br />
containing the help message is created after defining the variables which contain the url for the help file.<br />
</td><br />
</tr><br />
<br />
<br />
<!-- Answer evaluation section --><br />
<br />
</table><br />
<br />
<p style="text-align:center;"><br />
[[SubjectAreaTemplates|Templates by Subject Area]]<br />
</p><br />
<br />
[[Category:Applets]]<br />
[[Category:Sample Problems]]<br />
[[Category:Subject Area Templates]]<br />
<br />
<br />
<p style="text-align:center;"><br />
[[IndexOfProblemTechniques|Problem Techniques Index]]<br/><br />
<br />
</p><br />
<br />
[[Category:Problem Techniques]]<br />
<br />
<!--<br />
<ul><br />
<li>POD documentation: [http://webwork.maa.org/pod/pg_TRUNK/macros/AppletObjects.pl.html AppletObjects.pl.html]</li><br />
<li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/AppletObjects.pl?view=log AppletObjects.pl]</li><br />
<br />
</ul><br />
--></div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Writing_Your_Own_Homework_Problems_Using_PGML&diff=14443Writing Your Own Homework Problems Using PGML2016-03-12T16:36:12Z<p>Dpvc: Don't use redundant Compute() in PGML answers</p>
<hr />
<div>= Intro To Writing Your Own Homework Problems Using PGML =<br />
<br />
== Introduction ==<br />
* PGML makes writing your own homework problems so much nicer than what came before. Many chores which previously were difficult are now easier, if not automated away. The best part is that there is little to learn to get started. PGML is so elegant and intuitive that you can often get started by simply viewing and tweaking existing PGML based problem files.<br />
<br />
<br />
== So Why Isn't PGML Used Everywhere If It Is So Great? ==<br />
* If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.<br />
<br />
<br />
== Typical PGML Problem Example ==<br />
<br />
DOCUMENT();<br />
loadMacros(<br />
"PGstandard.pl",<br />
"PGML.pl",<br />
"MathObjects.pl",<br />
"PGcourse.pl",<br />
"parserNumberWithUnits.pl",<br />
"contextArbitraryString.pl",<br />
"parserMultiAnswer.pl",<br />
"parserPopUp.pl",<br />
"contextInequalities.pl",<br />
"PGgraphmacros.pl",<br />
);<br />
TEXT(beginproblem());<br />
$showPartialCorrectAnswers = 1;<br />
<br />
The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features<br />
you use in your problems, you may or may not need all the macros I have loaded above. On the other hand, one strategy is to<br />
always include any and every macro you have ever used in the past, or will use in the future, so as to not have to bother thinking about this initial boilerplate.<br />
<br />
Context("Numeric") ; <br />
Context()->flags->set(tolerance => 0.01);<br />
<br />
You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less. <br />
<br />
######################################################################<br />
BEGIN_PGML<br />
Simplify [`2 + 4 \cdot 5`].<br />
[____________]{"22"}<br />
Now simplify [`2x + 4x + 5x`].<br />
[____________]{"11x"}<br />
END_PGML<br />
######################################################################<br />
<br />
The is what you will be changing the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enclose it inside [` and `]. Your answer field is represented by [____________]. After the answer field, you specify the correct answer you desire in braces. In this example, the correct answer for the first question is a number and for the second it is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. Your problems can have only 1 question or even more than 2 if you wish. By the way, the hash marks which being and end this section are optional. I include them so I can easily see this part of any PGML problem quickly and easily.<br />
<br />
ENDDOCUMENT();<br />
<br />
This last part is more boilerplate that should not change much if at all.<br />
<br />
== For Further Study ==<br />
<br />
* '''[[Introduction to PGML]]''' -- a more complete introduction to PGML<br />
* '''[[:Category:PGML|PGML Reference materia|]]''' -- full reference material on PGML<br />
<br />
For further exploration of PGML, see the many [https://courses1.webwork.maa.org/webwork2/cervone_course/PGML-examples/?login_practice_user=true|live PGML examples]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Writing_Your_Own_Homework_Problems_Using_PGML&diff=14442Writing Your Own Homework Problems Using PGML2016-03-12T16:34:15Z<p>Dpvc: Update links to include the actual documentation</p>
<hr />
<div>= Intro To Writing Your Own Homework Problems Using PGML =<br />
<br />
== Introduction ==<br />
* PGML makes writing your own homework problems so much nicer than what came before. Many chores which previously were difficult are now easier, if not automated away. The best part is that there is little to learn to get started. PGML is so elegant and intuitive that you can often get started by simply viewing and tweaking existing PGML based problem files.<br />
<br />
<br />
== So Why Isn't PGML Used Everywhere If It Is So Great? ==<br />
* If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.<br />
<br />
<br />
== Typical PGML Problem Example ==<br />
<br />
DOCUMENT();<br />
loadMacros(<br />
"PGstandard.pl",<br />
"PGML.pl",<br />
"MathObjects.pl",<br />
"PGcourse.pl",<br />
"parserNumberWithUnits.pl",<br />
"contextArbitraryString.pl",<br />
"parserMultiAnswer.pl",<br />
"parserPopUp.pl",<br />
"contextInequalities.pl",<br />
"PGgraphmacros.pl",<br />
);<br />
TEXT(beginproblem());<br />
$showPartialCorrectAnswers = 1;<br />
<br />
The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features<br />
you use in your problems, you may or may not need all the macros I have loaded above. On the other hand, one strategy is to<br />
always include any and every macro you have ever used in the past, or will use in the future, so as to not have to bother thinking about this initial boilerplate.<br />
<br />
Context("Numeric") ; <br />
Context()->flags->set(tolerance => 0.01);<br />
<br />
You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less. <br />
<br />
######################################################################<br />
BEGIN_PGML<br />
Simplify [`2 + 4 \cdot 5`].<br />
[____________]{Compute("22")}<br />
Now simplify [`2x + 4x + 5x`].<br />
[____________]{Compute("11*x")}<br />
END_PGML<br />
######################################################################<br />
<br />
The is what you will be changing the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enclose it inside [` and `]. Your answer field is represented by [____________]. After the answer field, you specify the correct answer you desire in braces. In this example, the correct answer for the first question is a number and for the second it is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. Your problems can have only 1 question or even more than 2 if you wish. By the way, the hash marks which being and end this section are optional. I include them so I can easily see this part of any PGML problem quickly and easily.<br />
<br />
ENDDOCUMENT();<br />
<br />
This last part is more boilerplate that should not change much if at all.<br />
<br />
== For Further Study ==<br />
<br />
* '''[[Introduction to PGML]]''' -- a more complete introduction to PGML<br />
* '''[[:Category:PGML|PGML Reference materia|]]''' -- full reference material on PGML<br />
<br />
For further exploration of PGML, see the many [https://courses1.webwork.maa.org/webwork2/cervone_course/PGML-examples/?login_practice_user=true|live PGML examples]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Escaping_Substitutions_-_PGML&diff=16453Escaping Substitutions - PGML2016-01-04T23:22:34Z<p>Dpvc: Make tags in $b show up rather than be processed.</p>
<hr />
<div>__TOC__<br />
== Escaped Substitutions ==<br />
<br />
When a variable or command is substituted into a problem in PGML, it will be inserted so that all the characters in the substitution will appear in the problem (special HTML and TeX chacaters and PGML command characters included). For example:<br />
<br />
$a = "[:x:]", $b = "&lt;b&gt;bold&lt;/b&gt;"; $c = "25%";<br />
BEGIN_PGML<br />
* [$a] (PGML specials not processed)<br />
* [$b] (HTML specials display verbatim)<br />
* [$c] (TeX specials not processed)<br />
END_PGML<br />
<br />
should produce a list like the following<br />
<br />
* [:x:] (PGML specials not processed)<br />
* &lt;b&gt;bold&lt;/b&gt; (HTML specials display verbatim)<br />
* 25% (TeX specials not processed)<br />
<br />
in both screen and hardcopy output.<br />
<br />
== Direct Substitutions ==<br />
<br />
You can prevent the special characters from being escaped by adding a star after the substitution. This will cause the value of the variable to be inserted into the output directly with no additional processing.<br />
<br />
BEGIN_PGML<br />
Escaped: [$BSMALL] not small [$ESMALL] <br />
Verbatim: [$BSMALL]* small [$ESMALL]*<br />
END_PGML<br />
<br />
should produce<br />
<br />
Escaped: &lt;SMALL&gt; not small &lt;/SMALL&gt;<br />
Verbatim: <small> small </small><br />
<br />
Note that the requirements for hardcopy output differ from those for screen output, so you need to be sure that your values are appropriate for the current output mode. This is most useful for the variables predefined by WeBWorK, like the <code>$BSMALL</code> and <code>$ESMALL</code> values in the example above, as these are set properly according to the active display mode.<br />
<br />
== PGML-Processed Substitutions ==<br />
<br />
Sometimes the contents of a variable may contain commands that you want to have processed by PGML after the value is inserted into the text. You can request that PGML interprets the contents of the variable by putting ''two'' stars after it rather than just one.<br />
<br />
$pgml = "more PGML math: [:x:], and some *bold* text";<br />
BEGIN_PGML<br />
An insertion with [$pgml]** in it.<br />
END_PGML<br />
<br />
will generate<br />
<br />
An insertion with more PGML math: <i>x</i>, and some <b>bold</b> text in it.<br />
<br />
With no stars (or one star), you would get<br />
<br />
An insertion with more PGML math: [:x:], and some *bold* text in it.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:Authors&diff=1766Category:Authors2015-06-10T01:46:50Z<p>Dpvc: /* Basic Information */ Reorganize to match Authors page (why are there two pages?)</p>
<hr />
<div><br />
==Templates==<br />
Most people write problems starting from templates. Problems from the OPL can be modified to suit individual needs, or existing problem templates can be used to create new problems.<br />
* '''[[Problem Techniques]]''' This page lists templates for WeBWorK problems in alphabetical order. This collection of templates can also be accessed through the associated category page: [[:Category:Problem Techniques]]<br />
* '''[[:Category:Subject Area Templates|Subject Area Templates]]''' Some may find it useful to use this page where templates are ordered by subject area.<br />
* '''[[:Category:Sample_Problems|Sample_Problems]]''' A third page with a collection of templates is this page of sample problems.<br />
<br />
==Basic Information==<br />
WeBWorK problems should be written with the use of MathObjects. Most of the templates mentioned above will include the MathObject Macros (recognizable by the line "MathObjects.pl" in the LoadMacros section of the code). For those who would like to read up on the basics of coding problems the following pages are recommended:<br />
* '''[[Problem Authoring Background Information]]''' -- includes a PG language overview, some comments about editing problems and ensuring server access.<br />
* '''[[:Category:MathObjects|MathObjects]]''' -- information on authoring problems using MathObjects.<br />
** '''[[MathObjects reference table]]''' -- a quick reference.<br />
** '''[[Introduction to Contexts]]''' -- how to use Numeric, Complex, Vector, Matrix, Interval, and other contexts in problems.<br />
** '''[[Reduction rules for MathObject Formulas]]''' -- a table of ''The Reduction Rules and their Actions''. <br />
** '''[https://testcourses.webwork.maa.org/webwork2/PREP14_Problem_Authoring/Workshop2/?login_practice_user=true Davide Cervone's presentation on MathObjects to PREP, June, 2014]'''<br />
* '''[[:Category:PGML|PGML]]''' -- information on authoring problem using the PGML markup language.<br />
** '''[[SampleProblem4 |Template 4]]''' -- the standard outline of a problem using PGML, which includes a ''tagging and description section'', ''an initialization section'', ''a problem set-up section'', ''a text section'', and optional ''answer and solution sections''.<br />
** '''[https://testcourses.webwork.maa.org/webwork2/PREP14_Problem_Authoring/Workshop3-PGML/?login_practice_user=true Davide Cervone's presentation on PGML to PREP, June, 2014]'''<br />
* '''[[PGLabs|PG-Labs]]''' -- try out code fragments on line including code fragments containing MathObjects and PGML. This is a quick way to learn the fine points of the MathObject and PGML syntax.<br />
<br />
== Reference documents and manuals ==<br />
* [[:Category:Applets|'''Applets''']], how to embed Flash and Java applets into WeBWorK questions. <br />
* '''[[SequentialProblems]]''' revealing the problem one step at a time<br />
* '''[http://webwork.maa.org/pod/pg_TRUNK/ POD]''' -- POD = "plain old documentation" -- original documentation embedded in the code files -- this is the place to find the most complete and most technical description of macro behaviors.<br />
* '''[[:File:WeBWorK_Problem_Authoring_Tutorial.pdf| WeBWorK Problem Authoring Tutorial]]''' aimed at people who already know TeX, but need to learn about Perl, PG, and MathObjects (pdf file).<br />
* '''[[Customize_Course|Customize Course]]''' This page includes a bit of code that allows student to obtain a new version of a problem.<br />
* '''[[TrainingAuthors |Notes on training authors]]''', and suggestions for further documentation-- Sam Hathaway<br />
* The Good Questions project at Cornell University [http://www.math.cornell.edu/~GoodQuestions/]<br />
* '''[[Converting CAPA problems for use with WeBWorK]]''' (This article has been retained as a historical document.)</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Introduction_to_PGML&diff=16412Introduction to PGML2015-05-31T10:19:51Z<p>Dpvc: Removed extra space in example</p>
<hr />
<div>== What is PGML? ==<br />
<br />
'''PGML''' stands for "PG Markup Language", and it provides a method of creating the text of a PG problem that is easier and more flexible than the traditional <code>BEGIN_TEXT/END_TEXT</code> approach. PGML is based on the [http://daringfireball.net/projects/markdown/ Markdown] language that now underlies many blog and wiki software, so you may be familiar with some of its syntax already. Note, however, that there are many flavors of Markdown, and PGML may not implement everything exactly the same as the markdown dialect that you use elsewhere. There are also important additions to PGML specifically for working with PG, such as the ability to create answer blanks, or insert values of variables created earlier in the problem.<br />
<br />
PGML provides easy means of creating paragraphs, lists, headers, indentation, centering, and other formatting features. It also allows you to link the answer directly to its answer blank for easy problem maintenance. The underlying idea behind PGML is to make what you type as the text of the problem look as close to the result on screen as possible.<br />
<br />
PGML is for creating the ''text'' of the problem and for associating answers to their answer blanks. The setup and computational portion of the problem is still done in the traditional way. PGML integrates with [[:Category:MathObjects|MathObjects]] to make it easy to work with answers and answer checkers, and to present mathematics within the text of your problem.<br />
<br />
PGML can also be used to create the solutions to your problem, with many of the same advantages that you have for the text of the problem itself.<br />
<br />
== PGML Basics ==<br />
<br />
To use PGML, you need to include <code>PGML.pl</code> in your problem file via<br />
<br />
loadMacros("PGML.pl");<br />
<br />
Within your problem file, you can format a section of text using PGML by surrounding it with <code>BEGIN_PGML</code> and <code>END_PGML</code><br />
<br />
BEGIN_PGML<br />
... your PGML text goes here ...<br />
END_PGML<br />
<br />
Similarly, if you want to use PGML to generate your solution text, use<br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML solution text goes here ...<br />
END_PGML_SOLUTION<br />
<br />
These <code>BEGIN</code> and <code>END</code> commands must be on a line by themselves, though they can be indented.<br />
<br />
The formatting for the text that goes between them is described in more detail below, but PGML tries to make the formatting reflect the layout you have used within the <code>BEGIN/END</code>, and it uses the kinds of things you might type in an email message to indicate more advanced formatting. For example, a blank line indicates a paragraph break, indenting by 4 spaces indicates an indentation, asterisks and underlines indicate bold and italics, numbers at the beginning of a line indicates a numbered list, and so on.<br />
<br />
== Basic Formatting ==<br />
<br />
One of the underlying motivations of PGML is to try to make how you format the text within your problem file be reflected in the formatting when the problem is displayed on screen. So if you want to have some text be indented on screen, you simply indent it in when you are typing the problem. PGML formats your output based on standard conventions used in email or other text-based documents. Some of the more important of these conventions are described below. Full details can be found in the [[#Further Reading|Further Reading]] below.<br />
<br />
=== Paragraph and Line breaks ===<br />
<br />
Paragraphs are separated by a blank line (just as you would in an email message, for example).<br />
<br />
Paragraph one has a few lines<br />
of text, but ends here.<br />
<br />
This is paragraph two.<br />
<br />
Line breaks normally are ignored, so several lines of text will become one paragraph, and that will reflow to fill the horizontal space allocated to the problem. In the example above, the line break between "few lines" and "of text" may not be where the line breaks on screen. To force a line break within a paragraph, end the line with two consecutive spaces. So using <code style="white-space:nowrap">"a few lines "</code> in the example above would guarantee that the line break on screen comes after "lines".<br />
<br />
=== Indenting, Centering, and Justifying ===<br />
<br />
To indent a paragraph, insert 4 spaces before the first word of the paragraph.<br />
<br />
This paragraph is flush left.<br />
<br />
But this one is indented.<br />
<br />
Back to flush left.<br />
<br />
You only need to indent the first line of the paragraph, but is is OK to indent them all if that is easier to read.<br />
<br />
This is indented, but only the first line<br />
needs to have the four spaces. The others<br />
can be flush left.<br />
<br />
But you can indent all the lines of<br />
a paragraph if you want. That might<br />
be easier to read.<br />
<br />
You can have multiple indent levels:<br />
<br />
This is flush left.<br />
This is indented.<br />
<br />
This is also indented.<br />
And this is indented further.<br />
<br />
To center text, put <code>&gt;&gt;</code> and <code>&lt;&lt;</code> around it.<br />
<br />
>> Centered text <<<br />
<br />
>> Centered paragraph<br />
spanning more than one line. <<<br />
<br />
>> You can mark each <<<br />
>> line separately if you want <<<br />
>> and all lines will be combined <<<br />
>> into one centered paragraph. <<<br />
<br />
Put two spaces after the <code>&lt;&lt;</code> to force a line break within the centered paragraph.<br />
<br />
To right-justify some text, use just <code>&gt;&gt;</code> at the left<br />
<br />
>> Right-justified text<br />
<br />
>> Right-jutified paragraph<br />
spanning multiple lines.<br />
<br />
>> Right-justified paragraphs<br />
>> can have markers on<br />
>> each line.<br />
<br />
=== Lists ===<br />
<br />
You can create numbered, alphabetic, or bullet lists in PGML. Items in a numbered lists begin with a number followed by a period and at least one space.<br />
<br />
1. This is the first item<br />
2. This is the second item<br />
which spans several lines.<br />
<br />
A blank line ends the list, unless it is indented with four spaces, in which case it becomes a new paragraph in the previous numbered item.<br />
<br />
Here is a list:<br />
1. This is the first list item<br />
continued on the next line.<br />
2. Additional items are easy to add.<br />
3. Continuation need not be indented,<br />
such as this line.<br />
<br />
A paragraph break ends the list...<br />
1. Unless you indent the paragraph...<br />
<br />
...in which case it is part of the list item.<br />
2. See?<br />
<br />
Note that the actual numbers used don't matter. PGML will always number from 1 and increment by one each time. So<br />
<br />
1. Item A<br />
2. Item B<br />
3. Item C<br />
<br />
and<br />
<br />
8. Item A<br />
1. Item B<br />
3. Item C<br />
<br />
both produce the same numbered list in the output (numbered as in the first example).<br />
<br />
Alphabetic lists start with a letter followed by a period or a close parenthesis:<br />
<br />
A list with alphabetic markers:<br />
a) You can use dots<br />
b) or parens to indicate the items<br />
<br />
Roman numerals can be obtained using lists starting with roman numbers an a period:<br />
<br />
A list with roman numeral markers:<br />
i. Item 1<br />
ii. Item 2<br />
<br />
Uppercase letters or roman numerals produce lists with upper-case markers.<br />
<br />
Bullet lists begin with an asterisk or a dash. Plus signs produce square bullets, and <code>o</code> produces open circles.<br />
<br />
Bullets:<br />
* Item A<br />
* item B<br />
<br />
Squares:<br />
+ Item A'<br />
+ Item B'<br />
<br />
=== Emphasis ===<br />
<br />
Asterisks are used to indicate '''bold'', and underscores produce ''italics''. (Note: some Markdown processors use <code>*</code> for italics and <code>**</code> for bold; we may adopt that convention in the future.)<br />
<br />
This is *bold text*, and _italic text_.<br />
They can be combined as *_bold italic text_*.<br />
<br />
=== Mathematical Notation ===<br />
<br />
PGML allows you to specify mathematics in two different formats: TeX and calculator notation. The TeX notation allows you to use the standard TeX and LaTeX commands to format your mathematics. The calculator notation uses MathObjects to parse and format the mathematics (so this is the notation that you use to create formulas in your PG problems, and that students use to enter their answers). Both formats come in two forms: in-line and display style. The in-line form uses spacing rules that try to minimize the impact on line spacing, while display style allows for easier readability at the cost of using more vertical space.<br />
<br />
To use TeX-formatted mathematics, enclose it in <code>[`...`]</code> for in-line math and <code>[``...``]</code> for display-style math.<br />
<br />
To use calculator notation, enclose it in <code>[: ... :]</code> for in-line math and <code>[:: ... ::]</code> for display-style math.<br />
<br />
For example, <br />
<br />
What [`x`] makes [`\frac{x+2}{3} = 1`]?<br />
<br />
What [:x:] makes [:(x+2)/3 = 1:]?<br />
<br />
both produce the same results (with in-line math).<br />
<br />
Note that, unlike with TeX, display-mode math is not automatically centered on a separate line. If you want that, you must provide the formatting for that yourself:<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is flush left<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is indented<br />
<br />
>> [``\sum_{n=0}^{10} 2^n ``] is centered <<<br />
<br />
== Interaction with PG ==<br />
<br />
There are two important ways that PGML must interact with the rest of the PG problem: inserting the values of perl variables into the problem (e.g., the randomized parameters for the problem), and making the answer blanks where students will enter their answers and tying those blanks to the correct answers. Both of these are easy to do, and are described below.<br />
<br />
=== Variable Substitution ===<br />
<br />
To insert the value of a variable into your PGML text, enclose the variable name with <code>[...]</code>. For example, if you have a variable <code>$a</code> in your problem, then you can use<br />
<br />
BEGIN_PGML<br />
Suppose that a train leaves Chicago traveling [$a] miles per hour due south.<br />
END_PGML<br />
<br />
You can access array or hash entries similarly, e.g., <code>[$b[0]]</code> or <code>[$c{neg}]</code> or <code>[$d->{period}]</code>.<br />
<br />
Note that a variable that holds a [[:Category:MathObjects|MathObject]] can produce either a TeX string or a calculator-notation string; which one it produces depends on the context in which it is used. If it is inserted inside of TeX math delimiters (e.g., inside <code>[`...`]</code>), it will produce its TeX form, while if it is inserted inside calculator delimiters (e.g., <code>[: ... :]</code>), or not inside any delimiters, then it produces calculator-style notation. So if <code>$f = Formula("(x+1)/(x-1)")</code>, then<br />
<br />
Suppose [`f(x) = [$f]`].<br />
<br />
and<br />
<br />
Suppose [:f(x) = [$f]:].<br />
<br />
will both produce properly formatted mathematical output with no special handling needed on your part. (Note that this is in sharp contrast to the traditional <code>BEGIN_TEXT/END_TEXT</code> approach, which requires you to handle the TeX versions specially.)<br />
<br />
=== Answer Blanks ===<br />
<br />
One of the key ingredients in any WeBWorK problem is answer blanks where students can enter their answers. In PGML, these are created using <code>[_____]</code>, where the number of underscores indicates how wide the answer blank should be. For example<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]<br />
<br />
sets up an answer blank for the student to enter his or her value for <math>x^2</math>. The answer checker for this blank can be provided via <code>ANS()</code> in the traditional way. PGML provides an easier way to tie answers to answer blanks, however. Simply insert the answer inside braces following the answer blank:<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]{$a**2}<br />
<br />
Note that, as in this example, you can use a mathematical expression, or you could use a constant, or a variable. Here, you don't need to enclose the variable in brackets, as this is a perl expression, not PGML text.<br />
<br />
If your answer is a formula, enclose it in quotation marks<br />
<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{"x^2-1"}<br />
<br />
or use a Formula MathObject:<br />
<br />
$f = Compute("x^2-1");<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{$f}<br />
END_PGML<br />
<br />
If your expression has random parameter, you insert them as you would in a call to the MathObject <code>Compute()</code> command:<br />
<br />
$a = random(2,5,1);<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = [$a]`] and [`x = 0`]<br />
is [` y = `] [_______________________]{"x(x-$a)"}<br />
END_PGML<br />
<br />
(Again, no brackets are needed in the answer string).<br />
<br />
If you want to pass parameters to a MathObject answer checker, you can:<br />
<br />
$f = Compute("sqrt(x^2-10)");<br />
<br />
BEGIN_PGML<br />
The answer is [_________________]{$f->cmp(limits=>[4,6])}<br />
END_PGML<br />
<br />
This is just an overview of working with answer blanks. There are other possibilities for what you can pass as the answer, and how you can control the format of the answer blanks. See the documents linked below for more details.<br />
<br />
== Further Reading ==<br />
* '''[[:Category:PGML Syntax|PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[:Category:PGML Answers|Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=MathObject_Answers_-_PGML&diff=16472MathObject Answers - PGML2015-05-13T13:16:16Z<p>Dpvc: Move custom checker example to custom checkers section.</p>
<hr />
<div>== Answers from MathObejcts ==<br />
<br />
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to <code>Compute()</code>). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,<br />
<br />
Context("Interval");<br />
BEGIN_PGML<br />
The interval from 0 to 1 excluding 0 but<br />
including 1 is written: [___________]{"(0,1]"}<br />
END_PGML<br />
<br />
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.<br />
<br />
Instead of using quotation marks, you can use a MathObject creator function, like <code>Real()</code> or <code>Matrix()</code> if you prefer.<br />
<br />
Context("Complex");<br />
BEGIN_PGML<br />
As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)}<br />
END_PGML<br />
<br />
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.<br />
<br />
Context("Vector");<br />
<br />
$p = Point(0,2), $q = Point(1,-1);<br />
$v = Vector($q-$p);<br />
<br />
BEGIN_PGML<br />
A vector from [`[$p]`] to [`[$q]`] is [______________]{$v}<br />
END_PGML<br />
<br />
== Passing Options to Answer Checkers ==<br />
<br />
If you need to pass options to the answer checker for a MathObject, you can pass the answer checker to PGML rather than the MathObject itself.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$v->cmp(parallel=>true)}<br />
END_PGML<br />
<br />
Alternatively, you can save the answer checker in a variable and pass that to PGML for easier reading.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
$cmp = $v->cmp(parallel=>true);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$cmp}<br />
END_PGML<br />
<br />
This is particularly useful if you want to provide a [[#Custom_Checkers|custom checker]].<br />
<br />
== Answer Arrays ==<br />
<br />
For a Matrix, Vector, or Point object, you may want to ask the student to type each entry in a separate answer blank, rather than entering the whole object in one answer blank (for example, to prevent the use of vector calculations). In the traditional <code>BEGIN_TEXT/END_TEXT</code> setting, you would use its <code>an_array()</code> rather than its <code>ans_rule()</code> method.<br />
<br />
In PGML, you indicate that an answer blank should produce an answer array by putting an asterisk between the blank and the answer.<br />
<br />
Context("Matrix");<br />
$M = Matrix([1,2],[3,4]);<br />
<br />
BEGIN_PGML<br />
If [`M = [$M]`], then [`M^2 =`] [___]*{$M**2}<br />
END_PGML<br />
<br />
Here, the size of the answer rule determines the size of each rule in the answer array.<br />
<br />
== MultiAnswer Checkers ==<br />
<br />
To use a MultiAnswer object in PGML, create it outside the PGML block, and use the MultiAnswer variable for more than one answer blank.<br />
<br />
loadMacros("parserMultiAnswer.pl");<br />
<br />
$mp = MultiAnswer(12,6)->with(<br />
singleResult => 1,<br />
separator => " and ",<br />
tex_separator => "\text{ and }",<br />
checker => sub {<br />
my $correct= shift; my $student = shift;<br />
my ($ca,$cb) = @$correct;<br />
my ($sa,$sb) = @$student;<br />
my $ok = ($ca == $sa && $cb == $sb) ||<br />
($ca == $sb && $cb == $sa);<br />
return ($ok ? (1,1) : (0,0));<br />
},<br />
);<br />
<br />
BEGIN_PGML<br />
[_______]{$mp} and [_______]{$mp}<br />
END_PGML<br />
<br />
See the [[http://webwork.maa.org/pod/pg_TRUNK/macros/parserMultiAnswer.pl.html documentation for parserMultiAnswer.pl]] for more details about using MultiAnswer objects.<br />
<br />
== Custom Checkers ==<br />
<br />
Since custom checkers for math objects usually consist of more than one line, it is awkward to include them within the PGML block itself. Instead, use a variable to store the answer checker with the custom checker and pass that to PGML.<br />
<br />
Context("Point");<br />
$a = random(2,10,1);<br />
$x = random(-5,5,1);<br />
$y = $a - $x;<br />
<br />
$cmp = Point($x,$y)->cmp(<br />
showCoordinateHints => 0, # doesn't make sense to give hints in this case<br />
checker => sub {<br />
my ($correct,$student,$ansHash) = @_; # get correct and student MathObjects<br />
my ($sx,$sy) = $student->value; # get coordinates of student answer<br />
return ($sx + $sy == $a ? 1 : 0); # return 1 if correct, 0 otherwise<br />
}<br />
);<br />
<br />
BEGIN_PGML<br />
Find a point [:(x,y):] that is a solution to [: x+y = [$a] :].<br />
<br />
[: (x,y) :] = [______________________]{$cmp}<br />
END_TEXT<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=MathObject_Answers_-_PGML&diff=16471MathObject Answers - PGML2015-05-13T13:11:24Z<p>Dpvc: /* MultiAnswer Checkers */</p>
<hr />
<div>== Answers from MathObejcts ==<br />
<br />
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to <code>Compute()</code>). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,<br />
<br />
Context("Interval");<br />
BEGIN_PGML<br />
The interval from 0 to 1 excluding 0 but<br />
including 1 is written: [___________]{"(0,1]"}<br />
END_PGML<br />
<br />
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.<br />
<br />
Instead of using quotation marks, you can use a MathObject creator function, like <code>Real()</code> or <code>Matrix()</code> if you prefer.<br />
<br />
Context("Complex");<br />
BEGIN_PGML<br />
As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)}<br />
END_PGML<br />
<br />
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.<br />
<br />
Context("Vector");<br />
<br />
$p = Point(0,2), $q = Point(1,-1);<br />
$v = Vector($q-$p);<br />
<br />
BEGIN_PGML<br />
A vector from [`[$p]`] to [`[$q]`] is [______________]{$v}<br />
END_PGML<br />
<br />
== Passing Options to Answer Checkers ==<br />
<br />
If you need to pass options to the answer checker for a MathObject, you can pass the answer checker to PGML rather than the MathObject itself.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$v->cmp(parallel=>true)}<br />
END_PGML<br />
<br />
Alternatively, you can save the answer checker in a variable and pass that to PGML for easier reading.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
$cmp = $v->cmp(parallel=>true);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$cmp}<br />
END_PGML<br />
<br />
This is particularly useful if you want to provide a custom checker.<br />
<br />
Context("Point");<br />
$a = random(2,10,1);<br />
$x = random(-5,5,1);<br />
$y = $a - $x;<br />
<br />
$cmp = Point($x,$y)->cmp(<br />
showCoordinateHints => 0, # doesn't make sense to give hints in this case<br />
checker => sub {<br />
my ($correct,$student,$ansHash) = @_; # get correct and student MathObjects<br />
my ($sx,$sy) = $student->value; # get coordinates of student answer<br />
return ($sx + $sy == $a ? 1 : 0); # return 1 if correct, 0 otherwise<br />
}<br />
);<br />
<br />
BEGIN_PGML<br />
Find a point [:(x,y):] that is a solution to [: x+y = [$a] :].<br />
<br />
[: (x,y) :] = [______________________]{$cmp}<br />
END_TEXT<br />
<br />
== Answer Arrays ==<br />
<br />
For a Matrix, Vector, or Point object, you may want to ask the student to type each entry in a separate answer blank, rather than entering the whole object in one answer blank (for example, to prevent the use of vector calculations). In the traditional <code>BEGIN_TEXT/END_TEXT</code> setting, you would use its <code>an_array()</code> rather than its <code>ans_rule()</code> method.<br />
<br />
In PGML, you indicate that an answer blank should produce an answer array by putting an asterisk between the blank and the answer.<br />
<br />
Context("Matrix");<br />
$M = Matrix([1,2],[3,4]);<br />
<br />
BEGIN_PGML<br />
If [`M = [$M]`], then [`M^2 =`] [___]*{$M**2}<br />
END_PGML<br />
<br />
Here, the size of the answer rule determines the size of each rule in the answer array.<br />
<br />
== MultiAnswer Checkers ==<br />
<br />
To use a MultiAnswer object in PGML, create it outside the PGML block, and use the MultiAnswer variable for more than one answer blank.<br />
<br />
loadMacros("parserMultiAnswer.pl");<br />
<br />
$mp = MultiAnswer(12,6)->with(<br />
singleResult => 1,<br />
separator => " and ",<br />
tex_separator => "\text{ and }",<br />
checker => sub {<br />
my $correct= shift; my $student = shift;<br />
my ($ca,$cb) = @$correct;<br />
my ($sa,$sb) = @$student;<br />
my $ok = ($ca == $sa && $cb == $sb) ||<br />
($ca == $sb && $cb == $sa);<br />
return ($ok ? (1,1) : (0,0));<br />
},<br />
);<br />
<br />
BEGIN_PGML<br />
[_______]{$mp} and [_______]{$mp}<br />
END_PGML<br />
<br />
See the [[http://webwork.maa.org/pod/pg_TRUNK/macros/parserMultiAnswer.pl.html documentation for parserMultiAnswer.pl]] for more details about using MultiAnswer objects.<br />
<br />
== Custom Checkers ==<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=MathObject_Answers_-_PGML&diff=16470MathObject Answers - PGML2015-05-13T13:04:52Z<p>Dpvc: /* Answer Arrays */</p>
<hr />
<div>== Answers from MathObejcts ==<br />
<br />
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to <code>Compute()</code>). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,<br />
<br />
Context("Interval");<br />
BEGIN_PGML<br />
The interval from 0 to 1 excluding 0 but<br />
including 1 is written: [___________]{"(0,1]"}<br />
END_PGML<br />
<br />
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.<br />
<br />
Instead of using quotation marks, you can use a MathObject creator function, like <code>Real()</code> or <code>Matrix()</code> if you prefer.<br />
<br />
Context("Complex");<br />
BEGIN_PGML<br />
As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)}<br />
END_PGML<br />
<br />
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.<br />
<br />
Context("Vector");<br />
<br />
$p = Point(0,2), $q = Point(1,-1);<br />
$v = Vector($q-$p);<br />
<br />
BEGIN_PGML<br />
A vector from [`[$p]`] to [`[$q]`] is [______________]{$v}<br />
END_PGML<br />
<br />
== Passing Options to Answer Checkers ==<br />
<br />
If you need to pass options to the answer checker for a MathObject, you can pass the answer checker to PGML rather than the MathObject itself.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$v->cmp(parallel=>true)}<br />
END_PGML<br />
<br />
Alternatively, you can save the answer checker in a variable and pass that to PGML for easier reading.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
$cmp = $v->cmp(parallel=>true);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$cmp}<br />
END_PGML<br />
<br />
This is particularly useful if you want to provide a custom checker.<br />
<br />
Context("Point");<br />
$a = random(2,10,1);<br />
$x = random(-5,5,1);<br />
$y = $a - $x;<br />
<br />
$cmp = Point($x,$y)->cmp(<br />
showCoordinateHints => 0, # doesn't make sense to give hints in this case<br />
checker => sub {<br />
my ($correct,$student,$ansHash) = @_; # get correct and student MathObjects<br />
my ($sx,$sy) = $student->value; # get coordinates of student answer<br />
return ($sx + $sy == $a ? 1 : 0); # return 1 if correct, 0 otherwise<br />
}<br />
);<br />
<br />
BEGIN_PGML<br />
Find a point [:(x,y):] that is a solution to [: x+y = [$a] :].<br />
<br />
[: (x,y) :] = [______________________]{$cmp}<br />
END_TEXT<br />
<br />
== Answer Arrays ==<br />
<br />
For a Matrix, Vector, or Point object, you may want to ask the student to type each entry in a separate answer blank, rather than entering the whole object in one answer blank (for example, to prevent the use of vector calculations). In the traditional <code>BEGIN_TEXT/END_TEXT</code> setting, you would use its <code>an_array()</code> rather than its <code>ans_rule()</code> method.<br />
<br />
In PGML, you indicate that an answer blank should produce an answer array by putting an asterisk between the blank and the answer.<br />
<br />
Context("Matrix");<br />
$M = Matrix([1,2],[3,4]);<br />
<br />
BEGIN_PGML<br />
If [`M = [$M]`], then [`M^2 =`] [___]*{$M**2}<br />
END_PGML<br />
<br />
Here, the size of the answer rule determines the size of each rule in the answer array.<br />
<br />
== MultiAnswer Checkers ==<br />
<br />
== Custom Checkers ==<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Answers&diff=16458Category:PGML Answers2015-05-13T12:53:23Z<p>Dpvc: Fix link to passing options to answer checkers</p>
<hr />
<div>=== Answer Checking in PGML ===<br />
<br />
Answer blanks in PGML are indicated by <code>[___________]</code> where the number of underscores determines the width of the answer blank on screen. Usually, the answer is tied to the blank by enclosing it in braces following the answer blank. (If not, you will need to use <code>ANS()</code> outside the PGML code to provide an answer checker for the blank.) For example:<br />
<br />
$f = Formula("sin(x)+x^2");<br />
$Df = $f->D;<br />
<br />
BEGIN_PGML<br />
If [:f(x) = [$f]:], then [:f'(x) = :] [______________________]{$Df}<br />
END_PGML<br />
<br />
produces a problem that displays a formula and asks for its derivative.<br />
<br />
The answer you provide can be given in a variety of formats. It can be a number or a variable containing a number, a string that represents a MathObject to be used as the answer or a variable holding a MathObject, or a number of other possible values. These are described below.<br />
<br />
=== References ===<br />
* [[Numeric Answers - PGML|Numeric Answers]]<br />
* [[Formula Answers - PGML|Formula Answers]]<br />
* [[MathObject Answers - PGML|MathObject Answers]]<br />
** [[MathObject Answers - PGML#Passing_Options_to_Answer_Checkers|Passing Options to Answer Checkers]]<br />
** [[MathObject Answers - PGML#Answer_Arrays|Answer Arrays]]<br />
** [[MathObject Answers - PGML#MultiAnswer_Checkers|MultiAnswer Checkers]]<br />
** [[MathObject Answers - PGML#Custom_Checkers|Custom Checkers]]<br />
* [[Traditional Answer Checkers - PGML|Traditional Answer Checkers]]<br />
* [[External Answer Checkers - PGML|External Answer Checkers]]<br />
* [[Answers in Option Form - PGML|Answers in Option Form]]<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=MathObject_Answers_-_PGML&diff=16469MathObject Answers - PGML2015-05-13T12:51:59Z<p>Dpvc: /* Passing Options to Answer Checkers */</p>
<hr />
<div>== Answers from MathObejcts ==<br />
<br />
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to <code>Compute()</code>). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,<br />
<br />
Context("Interval");<br />
BEGIN_PGML<br />
The interval from 0 to 1 excluding 0 but<br />
including 1 is written: [___________]{"(0,1]"}<br />
END_PGML<br />
<br />
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.<br />
<br />
Instead of using quotation marks, you can use a MathObject creator function, like <code>Real()</code> or <code>Matrix()</code> if you prefer.<br />
<br />
Context("Complex");<br />
BEGIN_PGML<br />
As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)}<br />
END_PGML<br />
<br />
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.<br />
<br />
Context("Vector");<br />
<br />
$p = Point(0,2), $q = Point(1,-1);<br />
$v = Vector($q-$p);<br />
<br />
BEGIN_PGML<br />
A vector from [`[$p]`] to [`[$q]`] is [______________]{$v}<br />
END_PGML<br />
<br />
== Passing Options to Answer Checkers ==<br />
<br />
If you need to pass options to the answer checker for a MathObject, you can pass the answer checker to PGML rather than the MathObject itself.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$v->cmp(parallel=>true)}<br />
END_PGML<br />
<br />
Alternatively, you can save the answer checker in a variable and pass that to PGML for easier reading.<br />
<br />
Context("Vector");<br />
$a = 3, $b = 5;<br />
$v = Vector(-$b,$a);<br />
$cmp = $v->cmp(parallel=>true);<br />
<br />
BEGIN_PGML<br />
A vector perpendicular to [: <[$a],[$b]> :]* is [_____________}{$cmp}<br />
END_PGML<br />
<br />
This is particularly useful if you want to provide a custom checker.<br />
<br />
Context("Point");<br />
$a = random(2,10,1);<br />
$x = random(-5,5,1);<br />
$y = $a - $x;<br />
<br />
$cmp = Point($x,$y)->cmp(<br />
showCoordinateHints => 0, # doesn't make sense to give hints in this case<br />
checker => sub {<br />
my ($correct,$student,$ansHash) = @_; # get correct and student MathObjects<br />
my ($sx,$sy) = $student->value; # get coordinates of student answer<br />
return ($sx + $sy == $a ? 1 : 0); # return 1 if correct, 0 otherwise<br />
}<br />
);<br />
<br />
BEGIN_PGML<br />
Find a point [:(x,y):] that is a solution to [: x+y = [$a] :].<br />
<br />
[: (x,y) :] = [______________________]{$cmp}<br />
END_TEXT<br />
<br />
== Answer Arrays ==<br />
<br />
== MultiAnswer Checkers ==<br />
<br />
== Custom Checkers ==<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=MathObject_Answers_-_PGML&diff=16468MathObject Answers - PGML2015-05-13T12:39:28Z<p>Dpvc: Initial section</p>
<hr />
<div>== Answers from MathObejcts ==<br />
<br />
When you specify an answer following an answer blank and provide a number or a swing containing a formula, PGML turns your answer into a MathObject (essentially by passing it to <code>Compute()</code>). So you can provide any sort of MathObject-based answer by enclosing it in quotation marks. For example,<br />
<br />
Context("Interval");<br />
BEGIN_PGML<br />
The interval from 0 to 1 excluding 0 but<br />
including 1 is written: [___________]{"(0,1]"}<br />
END_PGML<br />
<br />
provides an answer that is an interval. The answer is parsed in the current context, which is the Interval context in this example. This means that you are giving the answer exactly as the student will.<br />
<br />
Instead of using quotation marks, you can use a MathObject creator function, like <code>Real()</code> or <code>Matrix()</code> if you prefer.<br />
<br />
Context("Complex");<br />
BEGIN_PGML<br />
As a complex number, [: sqrt(-1) :] is written [__________]{Complex(0,1)}<br />
END_PGML<br />
<br />
If the determination of the answer involves computations, however, it may be more convenient to produce a MathObject earlier in the problem and pass that to PGML. You can do that by putting the variable that holds the math object into the braces following the answer blank.<br />
<br />
Context("Vector");<br />
<br />
$p = Point(0,2), $q = Point(1,-1);<br />
$v = Vector($q-$p);<br />
<br />
BEGIN_PGML<br />
A vector from [`[$p]`] to [`[$q]`] is [______________]{$v}<br />
END_PGML<br />
<br />
== Passing Options to Answer Checkers ==<br />
<br />
== Answer Arrays ==<br />
<br />
== MultiAnswer Checkers ==<br />
<br />
== Custom Checkers ==<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Answers_in_Option_Form_-_PGML&diff=16467Answers in Option Form - PGML2015-05-13T12:23:12Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== Specifying the Width of an Answer Rule ==<br />
<br />
Normally, the width of an answer blank in PGML is proportional to the number of underscores used in the brackets that defined the blank. So a longer answer blank uses more underscores. It is also possible to give the width of the answer blank numerically. To do so, put the width in braces following the answer.<br />
<br />
BEGIN_PGML<br />
This value of [: sqrt($a) :] is [_____]{sqrt($a)}{10}<br />
END_PGML<br />
<br />
Here, the width the answer answer rule will be 10 regardless of how many underscores are used.<br />
<br />
== Specifying Answers via Options ==<br />
<br />
Normally, the answer and optional width are given by enclosing them in braces following the answer blank. It is also possible to use key/value pairs to specify the answer and width (in any order).<br />
<br />
BEGIN_PGML<br />
This value of [: sqrt($a) :] is [_____]{width=>10, answer=>sqrt($a)}<br />
END_PGML<br />
<br />
This takes a little more space, but make the meanings of the values more clear. It also makes it possible to provide the width ''without'' providing an answer (if you are using <code>ANS()</code> to specify the answer checker).<br />
<br />
BEGIN_PGML<br />
This value of [: sqrt($a) :] is [_____]{width=>10}<br />
END_PGML<br />
ANS(Real(sqrt($a))->cmp);<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=External_Answer_Checkers_-_PGML&diff=16466External Answer Checkers - PGML2015-05-13T12:09:02Z<p>Dpvc: Initial version</p>
<hr />
<div>== Using ANS() with PGML ==<br />
<br />
Although it is customary to provide the correct answer right for an answer blank after the blank in the PGML code, it is also possible to provide the answer later using the <code>ANS()</code> macro, as is done with <code>BEGIN_TEXT/END_TEXT</code> blocks. To do this, simply don't put any braces after the answer blank.<br />
<br />
loadMacros("contextLimitedNumeric.pl");<br />
Context("LimitedNumeric");<br />
$a = 3; $b = 5;<br />
$answer = Real($a+$b);<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [_______]<br />
END_PGML<br />
<br />
ANS($answer->cmp);<br />
<br />
You can use all the traditional or MathObject based answer checkers this way.<br />
<br />
If there is more than one answer blank, then the answer checkers are paired with them by order, as usual.<br />
<br />
Context("Numeric");<br />
Context()->functions->disable("sqrt");<br />
Context()->operators->remove("^","**");<br />
$a = 16; $b = 9;<br />
$ra = Real(sqrt($a)); $rb = Real(sqrt($b));<br />
<br />
BEGIN_PGML<br />
The value of [: sqrt([$a]) :] is [___________] <br />
The value of [: sqrt([$b]) :] is [___________]<br />
END_PGML<br />
<br />
ANS(<br />
$ra->cmp,<br />
$rb->cmp<br />
);<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Traditional_Answer_Checkers_-_PGML&diff=16465Traditional Answer Checkers - PGML2015-05-13T11:54:22Z<p>Dpvc: Add example of using a variable</p>
<hr />
<div>== Using Traditional Answer Checkers ==<br />
<br />
The answer blanks in PGML usually use [[:Category:MathObjects]] to provide the answer checkers for them, but you can also use the traditional answer checkers, like <code>num_cmp()</code> and <code>str_cmp()</code> in PGML. To do so, simply include the traditional-answer-checker function-call in the braces following the answer blank.<br />
<br />
$a = 3; $b = 5;<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [________]{strict_num_cmp($a+$b)}<br />
END_PGML<br />
<br />
The traditional string answer checkers amy be useful to use, since they provide some options not available in MathObjects, and don't require setting up the context to include the desired strings.<br />
<br />
You can also store an answer checker in a variable and pass that to PGML:<br />
<br />
$a = 3; $b = 5;<br />
$cmp = strict_num_cmp($a+$b);<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [________]{$cmp}<br />
END_PGML<br />
<br />
This can make the text of your PGML block problem easier to read.<br />
<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML&diff=16396Category:PGML2015-05-12T16:12:57Z<p>Dpvc: Fix link to answer checker category</p>
<hr />
<div>=== Authoring Questions using PGML ===<br />
* '''[[Introduction to PGML]]''' -- everything you need to know to get started with PGML<br />
* '''[[:Category:PGML Syntax|PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[:Category:PGML Answers|Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
=== Resources ===<br />
* '''[[PGLabs|PG-Labs]]''' -- On-line labs for rendering of PG code. The second section is the PGML lab.<br />
* '''[https://testcourses.webwork.maa.org/webwork2/PREP14_Problem_Authoring/Workshop3-PGML/?login_practice_user=true Davide Cervone's presentation on PGML to PREP, June 23, 2014]'''<br />
<br />
[[Category:Authors]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Traditional_Answer_Checkers_-_PGML&diff=16464Traditional Answer Checkers - PGML2015-05-12T16:12:05Z<p>Dpvc: Initial version</p>
<hr />
<div>== Using Traditional Answer Checkers ==<br />
<br />
The answer blanks in PGML usually use [[:Category:MathObjects]] to provide the answer checkers for them, but you can also use the traditional answer checkers, like <code>num_cmp()</code> and <code>str_cmp()</code> in PGML. To do so, simply include the traditional-answer-checker function-call in the braces following the answer blank.<br />
<br />
$a = 3; $b = 5;<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [________]{strict_num_cmp($a+$b)}<br />
END_PGML<br />
<br />
The traditional string answer checkers amy be useful to use, since they provide some options not available in MathObjects, and don't require setting up the context to include the desired strings.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Numeric_Answers_-_PGML&diff=16462Numeric Answers - PGML2015-05-12T15:50:49Z<p>Dpvc: Add link to MathObject Answers</p>
<hr />
<div>== Numeric Answer Checkers ==<br />
<br />
To use a number as an answer, just put the number in braces after the answer blank:<br />
<br />
BEGIN_PGML<br />
The value of [: 3 + 5 :] is [______]{8}<br />
END_PGML<br />
<br />
The value can be stored in a variable:<br />
<br />
$a = 3; $b = 5;<br />
$answer = $a + $b;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [______]{$answer}<br />
END_PGML<br />
<br />
or it can be an expression producing the value:<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [______]{$a+$b}<br />
END_PGML<br />
<br />
The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well<br />
<br />
$a = 3; $b = 5;<br />
$answer = Compute("$a + $b");<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [______]{$answer}<br />
END_PGML<br />
<br />
It is also possible to put the number (or formula leading to the number) in quotation marks, though this isn't necessary. If you do, however, the correct answer will be shown as the formula you used rather than the numeric value itself.<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b] :] is [______]{"$a + $b"}<br />
END_PGML<br />
<br />
will show "3 + 5" as the correct answer, not 8. ('''Note:''' this requires a recent version of PGML.pl)<br />
<br />
See the section on [[MathObject Answers - PGML|MathObject Answers]] for details on how to provide additional control over the MathObject answer checkers.<br />
<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Formula_Answers_-_PGML&diff=16463Formula Answers - PGML2015-05-12T15:49:57Z<p>Dpvc: Initial version</p>
<hr />
<div>== Formula Answer Checkers ==<br />
<br />
To use a formula as an answer, put the formula in quotation marks inside braces after the answer blank:<br />
<br />
BEGIN_PGML<br />
The square root of [:x:] is written [__________]{"sqrt(x)"}<br />
END_PGML<br />
<br />
Note that the quotation marks are ''required'', so don't forget them.<br />
<br />
The formula can be stored in a variable:<br />
<br />
$a = 3; $b = 5;<br />
$answer = "$a + $b x";<br />
<br />
BEGIN_PGML<br />
The formula is [______]{$answer}<br />
END_PGML<br />
<br />
The formula can be a MathObject Formula as well<br />
<br />
$a = 3; $b = 5;<br />
$answer = Compute("$a + $b x");<br />
<br />
BEGIN_PGML<br />
The formula is [______]{$answer}<br />
END_PGML<br />
<br />
See the section on [[MathObject Answers - PGML|MathObject Answers]] for details on how to provide additional control over the MathObject answer checkers.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Answers&diff=16457Category:PGML Answers2015-05-12T00:04:39Z<p>Dpvc: Removed a link that is covered in the first two items.</p>
<hr />
<div>=== Answer Checking in PGML ===<br />
<br />
Answer blanks in PGML are indicated by <code>[___________]</code> where the number of underscores determines the width of the answer blank on screen. Usually, the answer is tied to the blank by enclosing it in braces following the answer blank. (If not, you will need to use <code>ANS()</code> outside the PGML code to provide an answer checker for the blank.) For example:<br />
<br />
$f = Formula("sin(x)+x^2");<br />
$Df = $f->D;<br />
<br />
BEGIN_PGML<br />
If [:f(x) = [$f]:], then [:f'(x) = :] [______________________]{$Df}<br />
END_PGML<br />
<br />
produces a problem that displays a formula and asks for its derivative.<br />
<br />
The answer you provide can be given in a variety of formats. It can be a number or a variable containing a number, a string that represents a MathObject to be used as the answer or a variable holding a MathObject, or a number of other possible values. These are described below.<br />
<br />
=== References ===<br />
* [[Numeric Answers - PGML|Numeric Answers]]<br />
* [[Formula Answers - PGML|Formula Answers]]<br />
* [[MathObject Answers - PGML|MathObject Answers]]<br />
** [[MathObject Answers - PGML#Passing_Options_To_Answer_Checkers|Passing Options to Answer Checkers]]<br />
** [[MathObject Answers - PGML#Answer_Arrays|Answer Arrays]]<br />
** [[MathObject Answers - PGML#MultiAnswer_Checkers|MultiAnswer Checkers]]<br />
** [[MathObject Answers - PGML#Custom_Checkers|Custom Checkers]]<br />
* [[Traditional Answer Checkers - PGML|Traditional Answer Checkers]]<br />
* [[External Answer Checkers - PGML|External Answer Checkers]]<br />
* [[Answers in Option Form - PGML|Answers in Option Form]]<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Numeric_Answers_-_PGML&diff=16461Numeric Answers - PGML2015-05-12T00:03:21Z<p>Dpvc: Add PGML Sytnax category</p>
<hr />
<div>== Numeric Answer Checkers ==<br />
<br />
To use a number as an answer, just put the number in braces after the answer blank:<br />
<br />
BEGIN_PGML<br />
The value of [: 3 + 5:] is [______]{8}<br />
END_PGML<br />
<br />
The value can be stored in a variable:<br />
<br />
$a = 3; $b = 5;<br />
$answer = $a + $b;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
or it can be an expression producing the value:<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$a+$b}<br />
END_PGML<br />
<br />
The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well<br />
<br />
$a = 3; $b = 5;<br />
$answer = Compute("$a + $b");<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
It is also possible to put the number (or formula leading to the number) in quotation marks, though this isn't necessary. If you do, however, the correct answer will be shown as the formula you used rather than the numeric value itself.<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{"$a + $b"}<br />
END_PGML<br />
<br />
will show "3 + 5" as the correct answer, not 8. ('''Note:''' this requires a recent version of PGML.pl)<br />
<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Numeric_Answers_-_PGML&diff=16460Numeric Answers - PGML2015-05-12T00:02:13Z<p>Dpvc: Examples of quoted answers</p>
<hr />
<div>== Numeric Answer Checkers ==<br />
<br />
To use a number as an answer, just put the number in braces after the answer blank:<br />
<br />
BEGIN_PGML<br />
The value of [: 3 + 5:] is [______]{8}<br />
END_PGML<br />
<br />
The value can be stored in a variable:<br />
<br />
$a = 3; $b = 5;<br />
$answer = $a + $b;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
or it can be an expression producing the value:<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$a+$b}<br />
END_PGML<br />
<br />
The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well<br />
<br />
$a = 3; $b = 5;<br />
$answer = Compute("$a + $b");<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
It is also possible to put the number (or formula leading to the number) in quotation marks, though this isn't necessary. If you do, however, the correct answer will be shown as the formula you used rather than the numeric value itself.<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{"$a + $b"}<br />
END_PGML<br />
<br />
will show "3 + 5" as the correct answer, not 8. ('''Note:''' this requires a recent version of PGML.pl)<br />
<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Numeric_Answers_-_PGML&diff=16459Numeric Answers - PGML2015-05-11T23:45:08Z<p>Dpvc: Initial version</p>
<hr />
<div>== Numeric Answer Checkers ==<br />
<br />
To use a number as an answer, just put the number in braces after the answer blank:<br />
<br />
BEGIN_PGML<br />
The value of [: 3 + 5:] is [______]{8}<br />
END_PGML<br />
<br />
The value can be stored in a variable:<br />
<br />
$a = 3; $b = 5;<br />
$answer = $a + $b;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
or it can be an expression producing the value:<br />
<br />
$a = 3; $b = 5;<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$a+$b}<br />
END_PGML<br />
<br />
The number can be a MathObject Real or Complex, or Fraction, or other numeric value as well<br />
<br />
$a = 3; $b = 5;<br />
$answer = Compute("$a + $b");<br />
<br />
BEGIN_PGML<br />
The value of [: [$a] + [$b]:] is [______]{$answer}<br />
END_PGML<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Answers]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Answers&diff=16456Category:PGML Answers2015-05-11T23:40:38Z<p>Dpvc: Initial version</p>
<hr />
<div>=== Answer Checking in PGML ===<br />
<br />
Answer blanks in PGML are indicated by <code>[___________]</code> where the number of underscores determines the width of the answer blank on screen. Usually, the answer is tied to the blank by enclosing it in braces following the answer blank. (If not, you will need to use <code>ANS()</code> outside the PGML code to provide an answer checker for the blank.) For example:<br />
<br />
$f = Formula("sin(x)+x^2");<br />
$Df = $f->D;<br />
<br />
BEGIN_PGML<br />
If [:f(x) = [$f]:], then [:f'(x) = :] [______________________]{$Df}<br />
END_PGML<br />
<br />
produces a problem that displays a formula and asks for its derivative.<br />
<br />
The answer you provide can be given in a variety of formats. It can be a number or a variable containing a number, a string that represents a MathObject to be used as the answer or a variable holding a MathObject, or a number of other possible values. These are described below.<br />
<br />
=== References ===<br />
* [[Numeric Answers - PGML|Numeric Answers]]<br />
* [[Formula Answers - PGML|Formula Answers]]<br />
* [[Answers from Variables - PGML|Answers from Variables]]<br />
* [[MathObject Answers - PGML|MathObject Answers]]<br />
** [[MathObject Answers - PGML#Passing_Options_To_Answer_Checkers|Passing Options to Answer Checkers]]<br />
** [[MathObject Answers - PGML#Answer_Arrays|Answer Arrays]]<br />
** [[MathObject Answers - PGML#MultiAnswer_Checkers|MultiAnswer Checkers]]<br />
** [[MathObject Answers - PGML#Custom_Checkers|Custom Checkers]]<br />
* [[Traditional Answer Checkers - PGML|Traditional Answer Checkers]]<br />
* [[External Answer Checkers - PGML|External Answer Checkers]]<br />
* [[Answers in Option Form - PGML|Answers in Option Form]]<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Loading_and_Use_-_PGML&diff=16455Loading and Use - PGML2015-05-11T23:20:47Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== Loading the macro file ==<br />
<br />
If you are going to use PGML in your problem, you must include <code>"PGML.pl"</code> in the <code>loadMacros()</code> call at the beginning of your problem.<br />
<br />
loadMacros("PGML.pl");<br />
<br />
If you don't, you'll get a message about <code>PGML::Format2</code> not being defined.<br />
<br />
== Producing Text using PGML ==<br />
<br />
The text that you want processed by PGML should be enclosed in <code>BEGIN_PGML</code> and <code>END_PGML</code>, each on a separate line. That is, <br />
<br />
BEGIN_PGML<br />
... your PGML code here ...<br />
END_PGML<br />
<br />
You can have as many such PGML sections as you like within one problem.<br />
<br />
== Producing Solutions using PGML ==<br />
<br />
The text of the solution should be enclosed in <code>BEGIN_PGML_SOLUTION</code> and <code>END_PGML_SOLUTION</code>, each on a separate line. That is, <br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML code here ...<br />
END_PGML_SOLUTION<br />
<br />
PGML's math formatting and command substitution commands are particularly useful here, as you can include intermediate computations directly within the PGML itself:<br />
<br />
BEGIN_PGML_SOLUTION<br />
If [:x = [$a]:], then [:x+1 = ([$a]+1) = [@ $a+1 @]:]<br />
END_PGML_SOLUTION<br />
<br />
There is no need to use a separate variable for the value of <code>$a+1</code>, as the result of this computation will be inserted into the solution at that point.<br />
<br />
== Producing Hints using PGML ==<br />
<br />
The text for the hint should be enclosed in <code>BEGIN_PGML_HINT</code> and <code>END_PGML_HINT</code>, each on a separate line. That is, <br />
<br />
BEGIN_PGML_HINT<br />
... your PGML code here ...<br />
END_PGML_HINT<br />
<br />
As with solutions, you can perform computations and mathematical typesetting within the PGML hint:<br />
<br />
BEGIN_PGML_HINT<br />
What happens when [:x = [@ $a - $b @]:]?<br />
END_PGML_HINT<br />
<br />
There is no need for a separate variable for the value of <code>$a-$b</code>.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Comments_-_PGML&diff=16454Comments - PGML2015-05-11T23:04:44Z<p>Dpvc: Initial version</p>
<hr />
<div>== Comments in PGML ==<br />
<br />
Comments in PGML are placed within <code>[% ... %]</code>. They can be used to comment out PGML commands or even partial commands, and they can be nested.<br />
<br />
This [% text %] is removed. <br />
So are these [% partial [@ and incomplete %] commands. <br />
Comments can be nested [% one [% two %] back to one %]<br />
<br />
This lets you comment out whole sections of the text if you want:<br />
<br />
This text is shown.<br />
[%<br />
But this whole paragraph<br />
is not going to be shown<br />
until we remove the<br />
comment symbols.<br />
%]<br />
This is shown (and is part of the <br />
same paragraph as the first line).<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Escaping_Substitutions_-_PGML&diff=16452Escaping Substitutions - PGML2015-05-11T22:59:38Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== Escaped Substitutions ==<br />
<br />
When a variable or command is substituted into a problem in PGML, it will be inserted so that all the characters in the substitution will appear in the problem (special HTML and TeX chacaters and PGML command characters included). For example:<br />
<br />
$a = "[:x:]", $b = "<b>bold</b>"; $c = "25%";<br />
BEGIN_PGML<br />
* [$a] (PGML specials not processed)<br />
* [$b] (HTML specials display verbatim)<br />
* [$c] (TeX specials not processed)<br />
END_PGML<br />
<br />
should produce a list like the following<br />
<br />
* [:x:] (PGML specials not processed)<br />
* &lt;b&gt;bold&lt;/b&gt; (HTML specials display verbatim)<br />
* 25% (TeX specials not processed)<br />
<br />
in both screen and hardcopy output.<br />
<br />
== Direct Substitutions ==<br />
<br />
You can prevent the special characters from being escaped by adding a star after the substitution. This will cause the value of the variable to be inserted into the output directly with no additional processing.<br />
<br />
BEGIN_PGML<br />
Escaped: [$BSMALL] not small [$ESMALL] <br />
Verbatim: [$BSMALL]* small [$ESMALL]*<br />
END_PGML<br />
<br />
should produce<br />
<br />
Escaped: &lt;SMALL&gt; not small &lt;/SMALL&gt;<br />
Verbatim: <small> small </small><br />
<br />
Note that the requirements for hardcopy output differ from those for screen output, so you need to be sure that your values are appropriate for the current output mode. This is most useful for the variables predefined by WeBWorK, like the <code>$BSMALL</code> and <code>$ESMALL</code> values in the example above, as these are set properly according to the active display mode.<br />
<br />
== PGML-Processed Substitutions ==<br />
<br />
Sometimes the contents of a variable may contain commands that you want to have processed by PGML after the value is inserted into the text. You can request that PGML interprets the contents of the variable by putting ''two'' stars after it rather than just one.<br />
<br />
$pgml = "more PGML math: [:x:], and some *bold* text";<br />
BEGIN_PGML<br />
An insertion with [$pgml]** in it.<br />
END_PGML<br />
<br />
will generate<br />
<br />
An insertion with more PGML math: <i>x</i>, and some <b>bold</b> text in it.<br />
<br />
With no stars (or one star), you would get<br />
<br />
An insertion with more PGML math: [:x:], and some *bold* text in it.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Syntax&diff=16422Category:PGML Syntax2015-05-10T21:23:53Z<p>Dpvc: Fix link text</p>
<hr />
<div>__NOTOC__<br />
=== PGML Formatting Commands ===<br />
<br />
* '''[[Paragraph and line breaks - PGML|Paragraph and line breaks]]'''<br />
* '''[[Indenting, centering, justification - PGML|Indenting, centering, and right-justification]]'''<br />
* '''[[Lists and sub-lists - PGML|Lists and sub-lists]]'''<br />
* '''[[Emphasis - PGML|Emphasis]]'''<br />
* '''[[Mathematical notation - PGML|Mathematical Notation]]'''<br />
* '''[[Headings - PGML|Headings]]'''<br />
* '''[[Rules - PGML|Rules]]'''<br />
* '''[[Special Characters - PGML|Special Characters]]'''<br />
* '''[[Pre-formatted and verbatim text - PGML|Pre-formatted and verbatim text]]'''<br />
<br />
=== PGML Substitutions ===<br />
<br />
* '''[[Variable substitution - PGML|Variable substitution]]'''<br />
* '''[[Command substitution - PGML|Command substitution]]'''<br />
* '''[[Escaping Substitutions - PGML|Escaping Substitutions]]'''<br />
* '''[[Comments - PGML|Comments]]'''<br />
<br />
=== PGML Answer Checking ===<br />
* '''[[:Category:PGML Answers|Answer Blanks]]'''<br />
<br />
=== PGML in PG Problems ===<br />
* '''[[Loading and Use - PGML|Loading and Calling PGML]]'''<br />
<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Syntax&diff=16421Category:PGML Syntax2015-05-10T21:23:21Z<p>Dpvc: Reorder links</p>
<hr />
<div>__NOTOC__<br />
=== PGML Formatting Commands ===<br />
<br />
* '''[[Paragraph and line breaks - PGML|Paragraph and line breaks]]'''<br />
* '''[[Indenting, centering, justification - PGML|Indenting, centering, and right-justification]]'''<br />
* '''[[Lists and sub-lists - PGML|Lists and sub-lists]]'''<br />
* '''[[Emphasis - PGML|Emphasis]]'''<br />
* '''[[Mathematical notation - PGML|Mathematical Notation]]'''<br />
* '''[[Headings - PGML|Headings]]'''<br />
* '''[[Rules - PGML|Rules]]'''<br />
* '''[[Special Characters - PGML]]'''<br />
* '''[[Pre-formatted and verbatim text - PGML|Pre-formatted and verbatim text]]'''<br />
<br />
=== PGML Substitutions ===<br />
<br />
* '''[[Variable substitution - PGML|Variable substitution]]'''<br />
* '''[[Command substitution - PGML|Command substitution]]'''<br />
* '''[[Escaping Substitutions - PGML|Escaping Substitutions]]'''<br />
* '''[[Comments - PGML|Comments]]'''<br />
<br />
=== PGML Answer Checking ===<br />
* '''[[:Category:PGML Answers|Answer Blanks]]'''<br />
<br />
=== PGML in PG Problems ===<br />
* '''[[Loading and Use - PGML|Loading and Calling PGML]]'''<br />
<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Variable_substitution_-_PGML&diff=16450Variable substitution - PGML2015-05-10T21:22:41Z<p>Dpvc: Add link to Escaping Substitutions</p>
<hr />
<div>== Variable Substitution ==<br />
<br />
Frequently, you will have computed or randomly generated values that you want to include in the text of your problem. To insert the value of a <code>$a</code> into PGML, use <code>[$a]</code>. Such values can be inserted into the text anywhere, including inside math delimiters.<br />
<br />
Suppose a manufacturer produces [$n] cars at a cost of [$cost] per car.<br />
<br />
or<br />
<br />
Suppose [`f(x) = [$f]`]. Then [`f'(x) = `] [_________________].<br />
<br />
or<br />
<br />
Suppose [: f(x) = [$f] :]. Then [: f'(x) = :] [_________________].<br />
<br />
In the first example, the values of <code>$a</code> and <code>$cost</code> are inserted as plain text. In the second, example, if <code>$f</code> is a MathObject Formula, then its TeX form will be inserted and processed as TeX code (due to the <code>[`...`]</code> delimiters. In the third example, the Formula object's algebra string will be inserted into the math and processed in the [[Typeset Context]] documentation to generate the mathematical output.<br />
<br />
You can access array elements and hash entries as well.<br />
<br />
@A = (1,2,3); %B = (x => 1, y => 2); $C = [1,2,3]; $D = {x => 1, y => 2};<br />
BEGIN_PGML<br />
Array element: [$A[1]] produces 2 <br />
Hash element: [$B{x}] produces 1<br />
Array de-reference: [$C->[0]] produces 1<br />
Hash de-reference: [$D->{y}] produces 2<br />
END_PGML<br />
<br />
When a variable substitution is performed, the value of the variable will be displayed as part of the problem verbatim. So if the variable includes HTML code, for example, the code will be visible in the text, and will not have its normal formatting function. If you wish the HTML to be treated as actual HTML in the page, this can be accomplished. See the section on [[Escaping Substitutions - PGML|Escaping Substitutions]] for details.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Syntax&diff=16420Category:PGML Syntax2015-05-10T21:17:03Z<p>Dpvc: Fix link again</p>
<hr />
<div>__NOTOC__<br />
=== PGML Formatting Commands ===<br />
<br />
* '''[[Paragraph and line breaks - PGML|Paragraph and line breaks]]'''<br />
* '''[[Indenting, centering, justification - PGML|Indenting, centering, and right-justification]]'''<br />
* '''[[Lists and sub-lists - PGML|Lists and sub-lists]]'''<br />
* '''[[Emphasis - PGML|Emphasis]]'''<br />
* '''[[Mathematical notation - PGML|Mathematical Notation]]'''<br />
* '''[[Headings - PGML|Headings]]'''<br />
* '''[[Rules - PGML|Rules]]'''<br />
* '''[[Special Characters - PGML]]'''<br />
* '''[[Pre-formatted and verbatim text - PGML|Pre-formatted and verbatim text]]'''<br />
<br />
=== PGML Substitutions ===<br />
<br />
* '''[[Variable substitution - PGML|Variable substitution]]'''<br />
* '''[[Command substitution - PGML|Command substitution]]'''<br />
* '''[[Comments - PGML|Comments]]'''<br />
* '''[[Escaping Substitutions - PGML|Escaping Substitutions]]'''<br />
<br />
=== PGML Answer Checking ===<br />
* '''[[:Category:PGML Answers|Answer Blanks]]'''<br />
<br />
=== PGML in PG Problems ===<br />
* '''[[Loading and Use - PGML|Loading and Calling PGML]]'''<br />
<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Category:PGML_Syntax&diff=16419Category:PGML Syntax2015-05-10T21:16:31Z<p>Dpvc: Fix link text</p>
<hr />
<div>__NOTOC__<br />
=== PGML Formatting Commands ===<br />
<br />
* '''[[Paragraph and line breaks - PGML|Paragraph and line breaks]]'''<br />
* '''[[Indenting, centering, justification - PGML|Indenting, centering, and right-justification]]'''<br />
* '''[[Lists and sub-lists - PGML|Lists and sub-lists]]'''<br />
* '''[[Emphasis - PGML|Emphasis]]'''<br />
* '''[[Mathematical notation - PGML|Mathematical Notation]]'''<br />
* '''[[Headings - PGML|Headings]]'''<br />
* '''[[Rules - PGML|Rules]]'''<br />
* '''[[Special Characters - PGML]]'''<br />
* '''[[Pre-formatted and verbatim text - PGML|Pre-formatted and verbatim text]]'''<br />
<br />
=== PGML Substitutions ===<br />
<br />
* '''[[Variable substitution - PGML|Variable substitution]]'''<br />
* '''[[Command substitution - PGML|Command substitution]]'''<br />
* '''[[Comments - PGML|Comments]]'''<br />
* '''[[Escaping - PGML|Escaping Substitutions]]'''<br />
<br />
=== PGML Answer Checking ===<br />
* '''[[:Category:PGML Answers|Answer Blanks]]'''<br />
<br />
=== PGML in PG Problems ===<br />
* '''[[Loading and Use - PGML|Loading and Calling PGML]]'''<br />
<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Command_substitution_-_PGML&diff=16451Command substitution - PGML2015-05-10T21:16:05Z<p>Dpvc: Initial version</p>
<hr />
<div>== Command Substitution ==<br />
<br />
You can perform a perl command by surrounding it with <code>[@ ... @]</code> and its output will be placed into the problem at that point.<br />
<br />
The sum of 1 and 2 is [@ 1+2 @].<br />
<br />
You can use this inside math mode as well, which can help make it easier to produce solutions (without having to have lots of variables that contain intermediate results).<br />
<br />
To solve for [: x + [$a] = [$b]x :], subtract the [:x:] from both sides<br />
to get [: [$a] = [$b]x - x = ([$b] - 1) x = [@ $b-1 @] x:], and then<br />
divide by [: [@ $b-1 @] :] to get [: x = [$a]/[@ $b-1 @] =<br />
[@ Fraction($a,$b - 1)->reduce @] :].<br />
<br />
If the command produces output that is already formatted, follow it by a star.<br />
<br />
Enter your response: <br />
[@ ANS(String("none")->cmp); ans_box(3,40) @]*<br />
<br />
Since PGML doesn't include a means of producing an answer box, the example above shows how you can do so using the PG commands directly.<br />
<br />
Similarly, PGML doesn't yet include any direct support for images, but you can get them as in the following example<br />
<br />
[@ image(insertGraph($graph), width=>300, height=>300) @]*<br />
<br />
which inserts a graph created dynamically earlier in the problem.<br />
<br />
See the section on [[Escaping - PGML|Escaping Substitutions]] for more details about how the result will be interpreted when it is inserted into the output by PGML.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Variable_substitution_-_PGML&diff=16449Variable substitution - PGML2015-05-10T20:44:07Z<p>Dpvc: removed extra line break</p>
<hr />
<div>== Variable Substitution ==<br />
<br />
Frequently, you will have computed or randomly generated values that you want to include in the text of your problem. To insert the value of a <code>$a</code> into PGML, use <code>[$a]</code>. Such values can be inserted into the text anywhere, including inside math delimiters.<br />
<br />
Suppose a manufacturer produces [$n] cars at a cost of [$cost] per car.<br />
<br />
or<br />
<br />
Suppose [`f(x) = [$f]`]. Then [`f'(x) = `] [_________________].<br />
<br />
or<br />
<br />
Suppose [: f(x) = [$f] :]. Then [: f'(x) = :] [_________________].<br />
<br />
In the first example, the values of <code>$a</code> and <code>$cost</code> are inserted as plain text. In the second, example, if <code>$f</code> is a MathObject Formula, then its TeX form will be inserted and processed as TeX code (due to the <code>[`...`]</code> delimiters. In the third example, the Formula object's algebra string will be inserted into the math and processed in the [[Typeset Context]] to generate the mathematical output.<br />
<br />
You can access array elements and hash entries as well.<br />
<br />
@A = (1,2,3); %B = (x => 1, y => 2); $C = [1,2,3]; $D = {x => 1, y => 2};<br />
BEGIN_PGML<br />
Array element: [$A[1]] produces 2 <br />
Hash element: [$B{x}] produces 1<br />
Array de-reference: [$C->[0]] produces 1<br />
Hash de-reference: [$D->{y}] produces 2<br />
END_PGML<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Variable_substitution_-_PGML&diff=16448Variable substitution - PGML2015-05-10T20:43:46Z<p>Dpvc: Add hash and array element examples</p>
<hr />
<div>== Variable Substitution ==<br />
<br />
Frequently, you will have computed or randomly generated values that you want to include in the text of your problem. To insert the value of a <code>$a</code> into PGML, use <code>[$a]</code>. Such values can be inserted into the text anywhere, including inside math delimiters.<br />
<br />
Suppose a manufacturer produces [$n] cars at a cost of [$cost] per car.<br />
<br />
or<br />
<br />
Suppose [`f(x) = [$f]`]. Then [`f'(x) = `] [_________________].<br />
<br />
or<br />
<br />
Suppose [: f(x) = [$f] :]. Then [: f'(x) = :] [_________________].<br />
<br />
<br />
In the first example, the values of <code>$a</code> and <code>$cost</code> are inserted as plain text. In the second, example, if <code>$f</code> is a MathObject Formula, then its TeX form will be inserted and processed as TeX code (due to the <code>[`...`]</code> delimiters. In the third example, the Formula object's algebra string will be inserted into the math and processed in the [[Typeset Context]] to generate the mathematical output.<br />
<br />
You can access array elements and hash entries as well.<br />
<br />
@A = (1,2,3); %B = (x => 1, y => 2); $C = [1,2,3]; $D = {x => 1, y => 2};<br />
BEGIN_PGML<br />
Array element: [$A[1]] produces 2 <br />
Hash element: [$B{x}] produces 1<br />
Array de-reference: [$C->[0]] produces 1<br />
Hash de-reference: [$D->{y}] produces 2<br />
END_PGML<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Introduction_to_PGML&diff=16411Introduction to PGML2015-05-10T20:38:41Z<p>Dpvc: Put back hash and array element access (requires new version of PGML)</p>
<hr />
<div>== What is PGML? ==<br />
<br />
'''PGML''' stands for "PG Markup Language", and it provides a method of creating the text of a PG problem that is easier and more flexible than the traditional <code>BEGIN_TEXT/END_TEXT</code> approach. PGML is based on the [http://daringfireball.net/projects/markdown/ Markdown] language that now underlies many blog and wiki software, so you may be familiar with some of its syntax already. Note, however, that there are many flavors of Markdown, and PGML may not implement everything exactly the same as the markdown dialect that you use elsewhere. There are also important additions to PGML specifically for working with PG, such as the ability to create answer blanks, or insert values of variables created earlier in the problem.<br />
<br />
PGML provides easy means of creating paragraphs, lists, headers, indentation, centering, and other formatting features. It also allows you to link the answer directly to its answer blank for easy problem maintenance. The underlying idea behind PGML is to make what you type as the text of the problem look as close to the result on screen as possible.<br />
<br />
PGML is for creating the ''text'' of the problem and for associating answers to their answer blanks. The setup and computational portion of the problem is still done in the traditional way. PGML integrates with [[:Category:MathObjects|MathObjects]] to make it easy to work with answers and answer checkers, and to present mathematics within the text of your problem.<br />
<br />
PGML can also be used to create the solutions to your problem, with many of the same advantages that you have for the text of the problem itself.<br />
<br />
== PGML Basics ==<br />
<br />
To use PGML, you need to include <code>PGML.pl</code> in your problem file via<br />
<br />
loadMacros("PGML.pl");<br />
<br />
Within your problem file, you can format a section of text using PGML by surrounding it with <code>BEGIN_PGML</code> and <code>END_PGML</code><br />
<br />
BEGIN_PGML<br />
... your PGML text goes here ...<br />
END_PGML<br />
<br />
Similarly, if you want to use PGML to generate your solution text, use<br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML solution text goes here ...<br />
END_PGML_SOLUTION<br />
<br />
These <code>BEGIN</code> and <code>END</code> commands must be on a line by themselves, though they can be indented.<br />
<br />
The formatting for the text that goes between them is described in more detail below, but PGML tries to make the formatting reflect the layout you have used within the <code>BEGIN/END</code>, and it uses the kinds of things you might type in an email message to indicate more advanced formatting. For example, a blank line indicates a paragraph break, indenting by 4 spaces indicates an indentation, asterisks and underlines indicate bold and italics, numbers at the beginning of a line indicates a numbered list, and so on.<br />
<br />
== Basic Formatting ==<br />
<br />
One of the underlying motivations of PGML is to try to make how you format the text within your problem file be reflected in the formatting when the problem is displayed on screen. So if you want to have some text be indented on screen, you simply indent it in when you are typing the problem. PGML formats your output based on standard conventions used in email or other text-based documents. Some of the more important of these conventions are described below. Full details can be found in the [[#Further Reading|Further Reading]] below.<br />
<br />
=== Paragraph and Line breaks ===<br />
<br />
Paragraphs are separated by a blank line (just as you would in an email message, for example).<br />
<br />
Paragraph one has a few lines<br />
of text, but ends here.<br />
<br />
This is paragraph two.<br />
<br />
Line breaks normally are ignored, so several lines of text will become one paragraph, and that will reflow to fill the horizontal space allocated to the problem. In the example above, the line break between "few lines" and "of text" may not be where the line breaks on screen. To force a line break within a paragraph, end the line with two consecutive spaces. So using <code style="white-space:nowrap">"a few lines "</code> in the example above would guarantee that the line break on screen comes after "lines".<br />
<br />
=== Indenting, Centering, and Justifying ===<br />
<br />
To indent a paragraph, insert 4 spaces before the first word of the paragraph.<br />
<br />
This paragraph is flush left.<br />
<br />
But this one is indented.<br />
<br />
Back to flush left.<br />
<br />
You only need to indent the first line of the paragraph, but is is OK to indent them all if that is easier to read.<br />
<br />
This is indented, but only the first line<br />
needs to have the four spaces. The others<br />
can be flush left.<br />
<br />
But you can indent all the lines of<br />
a paragraph if you want. That might<br />
be easier to read.<br />
<br />
You can have multiple indent levels:<br />
<br />
This is flush left.<br />
This is indented.<br />
<br />
This is also indented.<br />
And this is indented further.<br />
<br />
To center text, put <code>&gt;&gt;</code> and <code>&lt;&lt;</code> around it.<br />
<br />
>> Centered text <<<br />
<br />
>> Centered paragraph<br />
spanning more than one line. <<<br />
<br />
>> You can mark each <<<br />
>> line separately if you want <<<br />
>> and all lines will be combined <<<br />
>> into one centered paragraph. <<<br />
<br />
Put two spaces after the <code>&lt;&lt;</code> to force a line break within the centered paragraph.<br />
<br />
To right-justify some text, use just <code>&gt;&gt;</code> at the left<br />
<br />
>> Right-justified text<br />
<br />
>> Right-jutified paragraph<br />
spanning multiple lines.<br />
<br />
>> Right-justified paragraphs<br />
>> can have markers on<br />
>> each line.<br />
<br />
=== Lists ===<br />
<br />
You can create numbered, alphabetic, or bullet lists in PGML. Items in a numbered lists begin with a number followed by a period and at least one space.<br />
<br />
1. This is the first item<br />
2. This is the second item<br />
which spans several lines.<br />
<br />
A blank line ends the list, unless it is indented with four spaces, in which case it becomes a new paragraph in the previous numbered item.<br />
<br />
Here is a list:<br />
1. This is the first list item<br />
continued on the next line.<br />
2. Additional items are easy to add.<br />
3. Continuation need not be indented,<br />
such as this line.<br />
<br />
A paragraph break ends the list...<br />
1. Unless you indent the paragraph...<br />
<br />
...in which case it is part of the list item.<br />
2. See?<br />
<br />
Note that the actual numbers used don't matter. PGML will always number from 1 and increment by one each time. So<br />
<br />
1. Item A<br />
2. Item B<br />
3. Item C<br />
<br />
and<br />
<br />
8. Item A<br />
1. Item B<br />
3. Item C<br />
<br />
both produce the same numbered list in the output (numbered as in the first example).<br />
<br />
Alphabetic lists start with a letter followed by a period or a close parenthesis:<br />
<br />
A list with alphabetic markers:<br />
a) You can use dots<br />
b) or parens to indicate the items<br />
<br />
Roman numerals can be obtained using lists starting with roman numbers an a period:<br />
<br />
A list with roman numeral markers:<br />
i. Item 1<br />
ii. Item 2<br />
<br />
Uppercase letters or roman numerals produce lists with upper-case markers.<br />
<br />
Bullet lists begin with an asterisk or a dash. Plus signs produce square bullets, and <code>o</code> produces open circles.<br />
<br />
Bullets:<br />
* Item A<br />
* item B<br />
<br />
Squares:<br />
+ Item A'<br />
+ Item B'<br />
<br />
=== Emphasis ===<br />
<br />
Asterisks are used to indicate '''bold'', and underscores produce ''italics''. (Note: some Markdown processors use <code>*</code> for italics and <code>**</code> for bold; we may adopt that convention in the future.)<br />
<br />
This is *bold text*, and _italic text_.<br />
They can be combined as *_bold italic text_*.<br />
<br />
=== Mathematical Notation ===<br />
<br />
PGML allows you to specify mathematics in two different formats: TeX and calculator notation. The TeX notation allows you to use the standard TeX and LaTeX commands to format your mathematics. The calculator notation uses MathObjects to parse and format the mathematics (so this is the notation that you use to create formulas in your PG problems, and that students use to enter their answers). Both formats come in two forms: in-line and display style. The in-line form uses spacing rules that try to minimize the impact on line spacing, while display style allows for easier readability at the cost of using more vertical space.<br />
<br />
To use TeX-formatted mathematics, enclose it in <code>[`...`]</code> for in-line math and <code>[``...``]</code> for display-style math.<br />
<br />
To use calculator notation, enclose it in <code>[: ... :]</code> for in-line math and <code>[:: ... ::]</code> for display-style math.<br />
<br />
For example, <br />
<br />
What [`x`] makes [`\frac{x+2}{3} = 1`]?<br />
<br />
What [:x:] makes [:(x+2)/3 = 1:]?<br />
<br />
both produce the same results (with in-line math).<br />
<br />
Note that, unlike with TeX, display-mode math is not automatically centered on a separate line. If you want that, you must provide the formatting for that yourself:<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is flush left<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is indented<br />
<br />
>> [``\sum_{n=0}^{10} 2^n ``] is centered <<<br />
<br />
== Interaction with PG ==<br />
<br />
There are two important ways that PGML must interact with the rest of the PG problem: inserting the values of perl variables into the problem (e.g., the randomized parameters for the problem), and making the answer blanks where students will enter their answers and tying those blanks to the correct answers. Both of these are easy to do, and are described below.<br />
<br />
=== Variable Substitution ===<br />
<br />
To insert the value of a variable into your PGML text, enclose the variable name with <code>[...]</code>. For example, if you have a variable <code>$a</code> in your problem, then you can use<br />
<br />
BEGIN_PGML<br />
Suppose that a train leaves Chicago traveling [$a] miles per hour due south.<br />
END_PGML<br />
<br />
You can access array or hash entries similarly, e.g., <code>[$b[0]]</code> or <code>[$c{neg}]</code> or <code>[$d->{period}]</code>.<br />
<br />
Note that a variable that holds a [[:Category:MathObjects|MathObject]] can produce either a TeX string or a calculator-notation string; which one it produces depends on the context in which it is used. If it is inserted inside of TeX math delimiters (e.g., inside <code>[`...`]</code>), it will produce its TeX form, while if it is inserted inside calculator delimiters (e.g., <code>[: ... :]</code>), or not inside any delimiters, then it produces calculator-style notation. So if <code>$f = Formula("(x+1)/(x-1)")</code>, then<br />
<br />
Suppose [`f(x) = [$f]`].<br />
<br />
and<br />
<br />
Suppose [:f(x) = [$f]:].<br />
<br />
will both produce properly formatted mathematical output with no special handling needed on your part. (Note that this is in sharp contrast to the traditional <code>BEGIN_TEXT/END_TEXT</code> approach, which requires you to handle the TeX versions specially.)<br />
<br />
=== Answer Blanks ===<br />
<br />
One of the key ingredients in any WeBWorK problem is answer blanks where students can enter their answers. In PGML, these are created using <code>[_____]</code>, where the number of underscores indicates how wide the answer blank should be. For example<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]<br />
<br />
sets up an answer blank for the student to enter his or her value for <math>x^2</math>. The answer checker for this blank can be provided via <code>ANS()</code> in the traditional way. PGML provides an easier way to tie answers to answer blanks, however. Simply insert the answer inside braces following the answer blank:<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]{$a**2}<br />
<br />
Note that, as in this example, you can use a mathematical expression, or you could use a constant, or a variable. Here, you don't need to enclose the variable in brackets, as this is a perl expression, not PGML text.<br />
<br />
If your answer is a formula, enclose it in quotation marks<br />
<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{"x^2-1"}<br />
<br />
or use a Formula MathObject:<br />
<br />
$f = Compute("x^2-1");<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{$f}<br />
END_PGML<br />
<br />
If your expression has random parameter, you insert them as you would in a call to the MathObject <code>Compute()</code> command:<br />
<br />
$a = random(2,5,1);<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = [$a]`] and [`x = 0`]<br />
is [` y = `] [_______________________]{"x(x-$a)"}<br />
END_PGML<br />
<br />
(Again, no brackets are needed in the answer string).<br />
<br />
If you want to pass parameters to a MathObject answer checker, you can:<br />
<br />
$f = Compute("sqrt(x^2-10)");<br />
<br />
BEGIN_PGML<br />
The answer is [_________________]{$f->cmp(limits=>[4,6])}<br />
END_PGML<br />
<br />
This is just an overview of working with answer blanks. There are other possibilities for what you can pass as the answer, and how you can control the format of the answer blanks. See the documents linked below for more details.<br />
<br />
== Further Reading ==<br />
* '''[[:Category:PGML Syntax|PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[:Category:PGML Answers|Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Introduction_to_PGML&diff=16410Introduction to PGML2015-05-10T19:29:48Z<p>Dpvc: /* Further Reading */</p>
<hr />
<div>== What is PGML? ==<br />
<br />
'''PGML''' stands for "PG Markup Language", and it provides a method of creating the text of a PG problem that is easier and more flexible than the traditional <code>BEGIN_TEXT/END_TEXT</code> approach. PGML is based on the [http://daringfireball.net/projects/markdown/ Markdown] language that now underlies many blog and wiki software, so you may be familiar with some of its syntax already. Note, however, that there are many flavors of Markdown, and PGML may not implement everything exactly the same as the markdown dialect that you use elsewhere. There are also important additions to PGML specifically for working with PG, such as the ability to create answer blanks, or insert values of variables created earlier in the problem.<br />
<br />
PGML provides easy means of creating paragraphs, lists, headers, indentation, centering, and other formatting features. It also allows you to link the answer directly to its answer blank for easy problem maintenance. The underlying idea behind PGML is to make what you type as the text of the problem look as close to the result on screen as possible.<br />
<br />
PGML is for creating the ''text'' of the problem and for associating answers to their answer blanks. The setup and computational portion of the problem is still done in the traditional way. PGML integrates with [[:Category:MathObjects|MathObjects]] to make it easy to work with answers and answer checkers, and to present mathematics within the text of your problem.<br />
<br />
PGML can also be used to create the solutions to your problem, with many of the same advantages that you have for the text of the problem itself.<br />
<br />
== PGML Basics ==<br />
<br />
To use PGML, you need to include <code>PGML.pl</code> in your problem file via<br />
<br />
loadMacros("PGML.pl");<br />
<br />
Within your problem file, you can format a section of text using PGML by surrounding it with <code>BEGIN_PGML</code> and <code>END_PGML</code><br />
<br />
BEGIN_PGML<br />
... your PGML text goes here ...<br />
END_PGML<br />
<br />
Similarly, if you want to use PGML to generate your solution text, use<br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML solution text goes here ...<br />
END_PGML_SOLUTION<br />
<br />
These <code>BEGIN</code> and <code>END</code> commands must be on a line by themselves, though they can be indented.<br />
<br />
The formatting for the text that goes between them is described in more detail below, but PGML tries to make the formatting reflect the layout you have used within the <code>BEGIN/END</code>, and it uses the kinds of things you might type in an email message to indicate more advanced formatting. For example, a blank line indicates a paragraph break, indenting by 4 spaces indicates an indentation, asterisks and underlines indicate bold and italics, numbers at the beginning of a line indicates a numbered list, and so on.<br />
<br />
== Basic Formatting ==<br />
<br />
One of the underlying motivations of PGML is to try to make how you format the text within your problem file be reflected in the formatting when the problem is displayed on screen. So if you want to have some text be indented on screen, you simply indent it in when you are typing the problem. PGML formats your output based on standard conventions used in email or other text-based documents. Some of the more important of these conventions are described below. Full details can be found in the [[#Further Reading|Further Reading]] below.<br />
<br />
=== Paragraph and Line breaks ===<br />
<br />
Paragraphs are separated by a blank line (just as you would in an email message, for example).<br />
<br />
Paragraph one has a few lines<br />
of text, but ends here.<br />
<br />
This is paragraph two.<br />
<br />
Line breaks normally are ignored, so several lines of text will become one paragraph, and that will reflow to fill the horizontal space allocated to the problem. In the example above, the line break between "few lines" and "of text" may not be where the line breaks on screen. To force a line break within a paragraph, end the line with two consecutive spaces. So using <code style="white-space:nowrap">"a few lines "</code> in the example above would guarantee that the line break on screen comes after "lines".<br />
<br />
=== Indenting, Centering, and Justifying ===<br />
<br />
To indent a paragraph, insert 4 spaces before the first word of the paragraph.<br />
<br />
This paragraph is flush left.<br />
<br />
But this one is indented.<br />
<br />
Back to flush left.<br />
<br />
You only need to indent the first line of the paragraph, but is is OK to indent them all if that is easier to read.<br />
<br />
This is indented, but only the first line<br />
needs to have the four spaces. The others<br />
can be flush left.<br />
<br />
But you can indent all the lines of<br />
a paragraph if you want. That might<br />
be easier to read.<br />
<br />
You can have multiple indent levels:<br />
<br />
This is flush left.<br />
This is indented.<br />
<br />
This is also indented.<br />
And this is indented further.<br />
<br />
To center text, put <code>&gt;&gt;</code> and <code>&lt;&lt;</code> around it.<br />
<br />
>> Centered text <<<br />
<br />
>> Centered paragraph<br />
spanning more than one line. <<<br />
<br />
>> You can mark each <<<br />
>> line separately if you want <<<br />
>> and all lines will be combined <<<br />
>> into one centered paragraph. <<<br />
<br />
Put two spaces after the <code>&lt;&lt;</code> to force a line break within the centered paragraph.<br />
<br />
To right-justify some text, use just <code>&gt;&gt;</code> at the left<br />
<br />
>> Right-justified text<br />
<br />
>> Right-jutified paragraph<br />
spanning multiple lines.<br />
<br />
>> Right-justified paragraphs<br />
>> can have markers on<br />
>> each line.<br />
<br />
=== Lists ===<br />
<br />
You can create numbered, alphabetic, or bullet lists in PGML. Items in a numbered lists begin with a number followed by a period and at least one space.<br />
<br />
1. This is the first item<br />
2. This is the second item<br />
which spans several lines.<br />
<br />
A blank line ends the list, unless it is indented with four spaces, in which case it becomes a new paragraph in the previous numbered item.<br />
<br />
Here is a list:<br />
1. This is the first list item<br />
continued on the next line.<br />
2. Additional items are easy to add.<br />
3. Continuation need not be indented,<br />
such as this line.<br />
<br />
A paragraph break ends the list...<br />
1. Unless you indent the paragraph...<br />
<br />
...in which case it is part of the list item.<br />
2. See?<br />
<br />
Note that the actual numbers used don't matter. PGML will always number from 1 and increment by one each time. So<br />
<br />
1. Item A<br />
2. Item B<br />
3. Item C<br />
<br />
and<br />
<br />
8. Item A<br />
1. Item B<br />
3. Item C<br />
<br />
both produce the same numbered list in the output (numbered as in the first example).<br />
<br />
Alphabetic lists start with a letter followed by a period or a close parenthesis:<br />
<br />
A list with alphabetic markers:<br />
a) You can use dots<br />
b) or parens to indicate the items<br />
<br />
Roman numerals can be obtained using lists starting with roman numbers an a period:<br />
<br />
A list with roman numeral markers:<br />
i. Item 1<br />
ii. Item 2<br />
<br />
Uppercase letters or roman numerals produce lists with upper-case markers.<br />
<br />
Bullet lists begin with an asterisk or a dash. Plus signs produce square bullets, and <code>o</code> produces open circles.<br />
<br />
Bullets:<br />
* Item A<br />
* item B<br />
<br />
Squares:<br />
+ Item A'<br />
+ Item B'<br />
<br />
=== Emphasis ===<br />
<br />
Asterisks are used to indicate '''bold'', and underscores produce ''italics''. (Note: some Markdown processors use <code>*</code> for italics and <code>**</code> for bold; we may adopt that convention in the future.)<br />
<br />
This is *bold text*, and _italic text_.<br />
They can be combined as *_bold italic text_*.<br />
<br />
=== Mathematical Notation ===<br />
<br />
PGML allows you to specify mathematics in two different formats: TeX and calculator notation. The TeX notation allows you to use the standard TeX and LaTeX commands to format your mathematics. The calculator notation uses MathObjects to parse and format the mathematics (so this is the notation that you use to create formulas in your PG problems, and that students use to enter their answers). Both formats come in two forms: in-line and display style. The in-line form uses spacing rules that try to minimize the impact on line spacing, while display style allows for easier readability at the cost of using more vertical space.<br />
<br />
To use TeX-formatted mathematics, enclose it in <code>[`...`]</code> for in-line math and <code>[``...``]</code> for display-style math.<br />
<br />
To use calculator notation, enclose it in <code>[: ... :]</code> for in-line math and <code>[:: ... ::]</code> for display-style math.<br />
<br />
For example, <br />
<br />
What [`x`] makes [`\frac{x+2}{3} = 1`]?<br />
<br />
What [:x:] makes [:(x+2)/3 = 1:]?<br />
<br />
both produce the same results (with in-line math).<br />
<br />
Note that, unlike with TeX, display-mode math is not automatically centered on a separate line. If you want that, you must provide the formatting for that yourself:<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is flush left<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is indented<br />
<br />
>> [``\sum_{n=0}^{10} 2^n ``] is centered <<<br />
<br />
== Interaction with PG ==<br />
<br />
There are two important ways that PGML must interact with the rest of the PG problem: inserting the values of perl variables into the problem (e.g., the randomized parameters for the problem), and making the answer blanks where students will enter their answers and tying those blanks to the correct answers. Both of these are easy to do, and are described below.<br />
<br />
=== Variable Substitution ===<br />
<br />
To insert the value of a variable into your PGML text, enclose the variable name with <code>[...]</code>. For example, if you have a variable <code>$a</code> in your problem, then you can use<br />
<br />
BEGIN_PGML<br />
Suppose that a train leaves Chicago traveling [$a] miles per hour due south.<br />
END_PGML<br />
<br />
Note that a variable that holds a [[:Category:MathObjects|MathObject]] can produce either a TeX string or a calculator-notation string; which one it produces depends on the context in which it is used. If it is inserted inside of TeX math delimiters (e.g., inside <code>[`...`]</code>), it will produce its TeX form, while if it is inserted inside calculator delimiters (e.g., <code>[: ... :]</code>), or not inside any delimiters, then it produces calculator-style notation. So if <code>$f = Formula("(x+1)/(x-1)")</code>, then<br />
<br />
Suppose [`f(x) = [$f]`].<br />
<br />
and<br />
<br />
Suppose [:f(x) = [$f]:].<br />
<br />
will both produce properly formatted mathematical output with no special handling needed on your part. (Note that this is in sharp contrast to the traditional <code>BEGIN_TEXT/END_TEXT</code> approach, which requires you to handle the TeX versions specially.)<br />
<br />
=== Answer Blanks ===<br />
<br />
One of the key ingredients in any WeBWorK problem is answer blanks where students can enter their answers. In PGML, these are created using <code>[_____]</code>, where the number of underscores indicates how wide the answer blank should be. For example<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]<br />
<br />
sets up an answer blank for the student to enter his or her value for <math>x^2</math>. The answer checker for this blank can be provided via <code>ANS()</code> in the traditional way. PGML provides an easier way to tie answers to answer blanks, however. Simply insert the answer inside braces following the answer blank:<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]{$a**2}<br />
<br />
Note that, as in this example, you can use a mathematical expression, or you could use a constant, or a variable. Here, you don't need to enclose the variable in brackets, as this is a perl expression, not PGML text.<br />
<br />
If your answer is a formula, enclose it in quotation marks<br />
<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{"x^2-1"}<br />
<br />
or use a Formula MathObject:<br />
<br />
$f = Compute("x^2-1");<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{$f}<br />
END_PGML<br />
<br />
If your expression has random parameter, you insert them as you would in a call to the MathObject <code>Compute()</code> command:<br />
<br />
$a = random(2,5,1);<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = [$a]`] and [`x = 0`]<br />
is [` y = `] [_______________________]{"x(x-$a)"}<br />
END_PGML<br />
<br />
(Again, no brackets are needed in the answer string).<br />
<br />
If you want to pass parameters to a MathObject answer checker, you can:<br />
<br />
$f = Compute("sqrt(x^2-10)");<br />
<br />
BEGIN_PGML<br />
The answer is [_________________]{$f->cmp(limits=>[4,6])}<br />
END_PGML<br />
<br />
This is just an overview of working with answer blanks. There are other possibilities for what you can pass as the answer, and how you can control the format of the answer blanks. See the documents linked below for more details.<br />
<br />
== Further Reading ==<br />
* '''[[:Category:PGML Syntax|PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[:Category:PGML Answers|Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Introduction_to_PGML&diff=16409Introduction to PGML2015-05-10T19:29:29Z<p>Dpvc: Fix links to categories</p>
<hr />
<div>== What is PGML? ==<br />
<br />
'''PGML''' stands for "PG Markup Language", and it provides a method of creating the text of a PG problem that is easier and more flexible than the traditional <code>BEGIN_TEXT/END_TEXT</code> approach. PGML is based on the [http://daringfireball.net/projects/markdown/ Markdown] language that now underlies many blog and wiki software, so you may be familiar with some of its syntax already. Note, however, that there are many flavors of Markdown, and PGML may not implement everything exactly the same as the markdown dialect that you use elsewhere. There are also important additions to PGML specifically for working with PG, such as the ability to create answer blanks, or insert values of variables created earlier in the problem.<br />
<br />
PGML provides easy means of creating paragraphs, lists, headers, indentation, centering, and other formatting features. It also allows you to link the answer directly to its answer blank for easy problem maintenance. The underlying idea behind PGML is to make what you type as the text of the problem look as close to the result on screen as possible.<br />
<br />
PGML is for creating the ''text'' of the problem and for associating answers to their answer blanks. The setup and computational portion of the problem is still done in the traditional way. PGML integrates with [[:Category:MathObjects|MathObjects]] to make it easy to work with answers and answer checkers, and to present mathematics within the text of your problem.<br />
<br />
PGML can also be used to create the solutions to your problem, with many of the same advantages that you have for the text of the problem itself.<br />
<br />
== PGML Basics ==<br />
<br />
To use PGML, you need to include <code>PGML.pl</code> in your problem file via<br />
<br />
loadMacros("PGML.pl");<br />
<br />
Within your problem file, you can format a section of text using PGML by surrounding it with <code>BEGIN_PGML</code> and <code>END_PGML</code><br />
<br />
BEGIN_PGML<br />
... your PGML text goes here ...<br />
END_PGML<br />
<br />
Similarly, if you want to use PGML to generate your solution text, use<br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML solution text goes here ...<br />
END_PGML_SOLUTION<br />
<br />
These <code>BEGIN</code> and <code>END</code> commands must be on a line by themselves, though they can be indented.<br />
<br />
The formatting for the text that goes between them is described in more detail below, but PGML tries to make the formatting reflect the layout you have used within the <code>BEGIN/END</code>, and it uses the kinds of things you might type in an email message to indicate more advanced formatting. For example, a blank line indicates a paragraph break, indenting by 4 spaces indicates an indentation, asterisks and underlines indicate bold and italics, numbers at the beginning of a line indicates a numbered list, and so on.<br />
<br />
== Basic Formatting ==<br />
<br />
One of the underlying motivations of PGML is to try to make how you format the text within your problem file be reflected in the formatting when the problem is displayed on screen. So if you want to have some text be indented on screen, you simply indent it in when you are typing the problem. PGML formats your output based on standard conventions used in email or other text-based documents. Some of the more important of these conventions are described below. Full details can be found in the [[#Further Reading|Further Reading]] below.<br />
<br />
=== Paragraph and Line breaks ===<br />
<br />
Paragraphs are separated by a blank line (just as you would in an email message, for example).<br />
<br />
Paragraph one has a few lines<br />
of text, but ends here.<br />
<br />
This is paragraph two.<br />
<br />
Line breaks normally are ignored, so several lines of text will become one paragraph, and that will reflow to fill the horizontal space allocated to the problem. In the example above, the line break between "few lines" and "of text" may not be where the line breaks on screen. To force a line break within a paragraph, end the line with two consecutive spaces. So using <code style="white-space:nowrap">"a few lines "</code> in the example above would guarantee that the line break on screen comes after "lines".<br />
<br />
=== Indenting, Centering, and Justifying ===<br />
<br />
To indent a paragraph, insert 4 spaces before the first word of the paragraph.<br />
<br />
This paragraph is flush left.<br />
<br />
But this one is indented.<br />
<br />
Back to flush left.<br />
<br />
You only need to indent the first line of the paragraph, but is is OK to indent them all if that is easier to read.<br />
<br />
This is indented, but only the first line<br />
needs to have the four spaces. The others<br />
can be flush left.<br />
<br />
But you can indent all the lines of<br />
a paragraph if you want. That might<br />
be easier to read.<br />
<br />
You can have multiple indent levels:<br />
<br />
This is flush left.<br />
This is indented.<br />
<br />
This is also indented.<br />
And this is indented further.<br />
<br />
To center text, put <code>&gt;&gt;</code> and <code>&lt;&lt;</code> around it.<br />
<br />
>> Centered text <<<br />
<br />
>> Centered paragraph<br />
spanning more than one line. <<<br />
<br />
>> You can mark each <<<br />
>> line separately if you want <<<br />
>> and all lines will be combined <<<br />
>> into one centered paragraph. <<<br />
<br />
Put two spaces after the <code>&lt;&lt;</code> to force a line break within the centered paragraph.<br />
<br />
To right-justify some text, use just <code>&gt;&gt;</code> at the left<br />
<br />
>> Right-justified text<br />
<br />
>> Right-jutified paragraph<br />
spanning multiple lines.<br />
<br />
>> Right-justified paragraphs<br />
>> can have markers on<br />
>> each line.<br />
<br />
=== Lists ===<br />
<br />
You can create numbered, alphabetic, or bullet lists in PGML. Items in a numbered lists begin with a number followed by a period and at least one space.<br />
<br />
1. This is the first item<br />
2. This is the second item<br />
which spans several lines.<br />
<br />
A blank line ends the list, unless it is indented with four spaces, in which case it becomes a new paragraph in the previous numbered item.<br />
<br />
Here is a list:<br />
1. This is the first list item<br />
continued on the next line.<br />
2. Additional items are easy to add.<br />
3. Continuation need not be indented,<br />
such as this line.<br />
<br />
A paragraph break ends the list...<br />
1. Unless you indent the paragraph...<br />
<br />
...in which case it is part of the list item.<br />
2. See?<br />
<br />
Note that the actual numbers used don't matter. PGML will always number from 1 and increment by one each time. So<br />
<br />
1. Item A<br />
2. Item B<br />
3. Item C<br />
<br />
and<br />
<br />
8. Item A<br />
1. Item B<br />
3. Item C<br />
<br />
both produce the same numbered list in the output (numbered as in the first example).<br />
<br />
Alphabetic lists start with a letter followed by a period or a close parenthesis:<br />
<br />
A list with alphabetic markers:<br />
a) You can use dots<br />
b) or parens to indicate the items<br />
<br />
Roman numerals can be obtained using lists starting with roman numbers an a period:<br />
<br />
A list with roman numeral markers:<br />
i. Item 1<br />
ii. Item 2<br />
<br />
Uppercase letters or roman numerals produce lists with upper-case markers.<br />
<br />
Bullet lists begin with an asterisk or a dash. Plus signs produce square bullets, and <code>o</code> produces open circles.<br />
<br />
Bullets:<br />
* Item A<br />
* item B<br />
<br />
Squares:<br />
+ Item A'<br />
+ Item B'<br />
<br />
=== Emphasis ===<br />
<br />
Asterisks are used to indicate '''bold'', and underscores produce ''italics''. (Note: some Markdown processors use <code>*</code> for italics and <code>**</code> for bold; we may adopt that convention in the future.)<br />
<br />
This is *bold text*, and _italic text_.<br />
They can be combined as *_bold italic text_*.<br />
<br />
=== Mathematical Notation ===<br />
<br />
PGML allows you to specify mathematics in two different formats: TeX and calculator notation. The TeX notation allows you to use the standard TeX and LaTeX commands to format your mathematics. The calculator notation uses MathObjects to parse and format the mathematics (so this is the notation that you use to create formulas in your PG problems, and that students use to enter their answers). Both formats come in two forms: in-line and display style. The in-line form uses spacing rules that try to minimize the impact on line spacing, while display style allows for easier readability at the cost of using more vertical space.<br />
<br />
To use TeX-formatted mathematics, enclose it in <code>[`...`]</code> for in-line math and <code>[``...``]</code> for display-style math.<br />
<br />
To use calculator notation, enclose it in <code>[: ... :]</code> for in-line math and <code>[:: ... ::]</code> for display-style math.<br />
<br />
For example, <br />
<br />
What [`x`] makes [`\frac{x+2}{3} = 1`]?<br />
<br />
What [:x:] makes [:(x+2)/3 = 1:]?<br />
<br />
both produce the same results (with in-line math).<br />
<br />
Note that, unlike with TeX, display-mode math is not automatically centered on a separate line. If you want that, you must provide the formatting for that yourself:<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is flush left<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is indented<br />
<br />
>> [``\sum_{n=0}^{10} 2^n ``] is centered <<<br />
<br />
== Interaction with PG ==<br />
<br />
There are two important ways that PGML must interact with the rest of the PG problem: inserting the values of perl variables into the problem (e.g., the randomized parameters for the problem), and making the answer blanks where students will enter their answers and tying those blanks to the correct answers. Both of these are easy to do, and are described below.<br />
<br />
=== Variable Substitution ===<br />
<br />
To insert the value of a variable into your PGML text, enclose the variable name with <code>[...]</code>. For example, if you have a variable <code>$a</code> in your problem, then you can use<br />
<br />
BEGIN_PGML<br />
Suppose that a train leaves Chicago traveling [$a] miles per hour due south.<br />
END_PGML<br />
<br />
Note that a variable that holds a [[:Category:MathObjects|MathObject]] can produce either a TeX string or a calculator-notation string; which one it produces depends on the context in which it is used. If it is inserted inside of TeX math delimiters (e.g., inside <code>[`...`]</code>), it will produce its TeX form, while if it is inserted inside calculator delimiters (e.g., <code>[: ... :]</code>), or not inside any delimiters, then it produces calculator-style notation. So if <code>$f = Formula("(x+1)/(x-1)")</code>, then<br />
<br />
Suppose [`f(x) = [$f]`].<br />
<br />
and<br />
<br />
Suppose [:f(x) = [$f]:].<br />
<br />
will both produce properly formatted mathematical output with no special handling needed on your part. (Note that this is in sharp contrast to the traditional <code>BEGIN_TEXT/END_TEXT</code> approach, which requires you to handle the TeX versions specially.)<br />
<br />
=== Answer Blanks ===<br />
<br />
One of the key ingredients in any WeBWorK problem is answer blanks where students can enter their answers. In PGML, these are created using <code>[_____]</code>, where the number of underscores indicates how wide the answer blank should be. For example<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]<br />
<br />
sets up an answer blank for the student to enter his or her value for <math>x^2</math>. The answer checker for this blank can be provided via <code>ANS()</code> in the traditional way. PGML provides an easier way to tie answers to answer blanks, however. Simply insert the answer inside braces following the answer blank:<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]{$a**2}<br />
<br />
Note that, as in this example, you can use a mathematical expression, or you could use a constant, or a variable. Here, you don't need to enclose the variable in brackets, as this is a perl expression, not PGML text.<br />
<br />
If your answer is a formula, enclose it in quotation marks<br />
<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{"x^2-1"}<br />
<br />
or use a Formula MathObject:<br />
<br />
$f = Compute("x^2-1");<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{$f}<br />
END_PGML<br />
<br />
If your expression has random parameter, you insert them as you would in a call to the MathObject <code>Compute()</code> command:<br />
<br />
$a = random(2,5,1);<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = [$a]`] and [`x = 0`]<br />
is [` y = `] [_______________________]{"x(x-$a)"}<br />
END_PGML<br />
<br />
(Again, no brackets are needed in the answer string).<br />
<br />
If you want to pass parameters to a MathObject answer checker, you can:<br />
<br />
$f = Compute("sqrt(x^2-10)");<br />
<br />
BEGIN_PGML<br />
The answer is [_________________]{$f->cmp(limits=>[4,6])}<br />
END_PGML<br />
<br />
This is just an overview of working with answer blanks. There are other possibilities for what you can pass as the answer, and how you can control the format of the answer blanks. See the documents linked below for more details.<br />
<br />
== Further Reading ==<br />
* '''[[Category:PGML Syntax|PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[Category:PGML Answers|Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Introduction_to_PGML&diff=16408Introduction to PGML2015-05-10T19:28:45Z<p>Dpvc: Removed incorrect selection of array hash elements</p>
<hr />
<div>== What is PGML? ==<br />
<br />
'''PGML''' stands for "PG Markup Language", and it provides a method of creating the text of a PG problem that is easier and more flexible than the traditional <code>BEGIN_TEXT/END_TEXT</code> approach. PGML is based on the [http://daringfireball.net/projects/markdown/ Markdown] language that now underlies many blog and wiki software, so you may be familiar with some of its syntax already. Note, however, that there are many flavors of Markdown, and PGML may not implement everything exactly the same as the markdown dialect that you use elsewhere. There are also important additions to PGML specifically for working with PG, such as the ability to create answer blanks, or insert values of variables created earlier in the problem.<br />
<br />
PGML provides easy means of creating paragraphs, lists, headers, indentation, centering, and other formatting features. It also allows you to link the answer directly to its answer blank for easy problem maintenance. The underlying idea behind PGML is to make what you type as the text of the problem look as close to the result on screen as possible.<br />
<br />
PGML is for creating the ''text'' of the problem and for associating answers to their answer blanks. The setup and computational portion of the problem is still done in the traditional way. PGML integrates with [[:Category:MathObjects|MathObjects]] to make it easy to work with answers and answer checkers, and to present mathematics within the text of your problem.<br />
<br />
PGML can also be used to create the solutions to your problem, with many of the same advantages that you have for the text of the problem itself.<br />
<br />
== PGML Basics ==<br />
<br />
To use PGML, you need to include <code>PGML.pl</code> in your problem file via<br />
<br />
loadMacros("PGML.pl");<br />
<br />
Within your problem file, you can format a section of text using PGML by surrounding it with <code>BEGIN_PGML</code> and <code>END_PGML</code><br />
<br />
BEGIN_PGML<br />
... your PGML text goes here ...<br />
END_PGML<br />
<br />
Similarly, if you want to use PGML to generate your solution text, use<br />
<br />
BEGIN_PGML_SOLUTION<br />
... your PGML solution text goes here ...<br />
END_PGML_SOLUTION<br />
<br />
These <code>BEGIN</code> and <code>END</code> commands must be on a line by themselves, though they can be indented.<br />
<br />
The formatting for the text that goes between them is described in more detail below, but PGML tries to make the formatting reflect the layout you have used within the <code>BEGIN/END</code>, and it uses the kinds of things you might type in an email message to indicate more advanced formatting. For example, a blank line indicates a paragraph break, indenting by 4 spaces indicates an indentation, asterisks and underlines indicate bold and italics, numbers at the beginning of a line indicates a numbered list, and so on.<br />
<br />
== Basic Formatting ==<br />
<br />
One of the underlying motivations of PGML is to try to make how you format the text within your problem file be reflected in the formatting when the problem is displayed on screen. So if you want to have some text be indented on screen, you simply indent it in when you are typing the problem. PGML formats your output based on standard conventions used in email or other text-based documents. Some of the more important of these conventions are described below. Full details can be found in the [[#Further Reading|Further Reading]] below.<br />
<br />
=== Paragraph and Line breaks ===<br />
<br />
Paragraphs are separated by a blank line (just as you would in an email message, for example).<br />
<br />
Paragraph one has a few lines<br />
of text, but ends here.<br />
<br />
This is paragraph two.<br />
<br />
Line breaks normally are ignored, so several lines of text will become one paragraph, and that will reflow to fill the horizontal space allocated to the problem. In the example above, the line break between "few lines" and "of text" may not be where the line breaks on screen. To force a line break within a paragraph, end the line with two consecutive spaces. So using <code style="white-space:nowrap">"a few lines "</code> in the example above would guarantee that the line break on screen comes after "lines".<br />
<br />
=== Indenting, Centering, and Justifying ===<br />
<br />
To indent a paragraph, insert 4 spaces before the first word of the paragraph.<br />
<br />
This paragraph is flush left.<br />
<br />
But this one is indented.<br />
<br />
Back to flush left.<br />
<br />
You only need to indent the first line of the paragraph, but is is OK to indent them all if that is easier to read.<br />
<br />
This is indented, but only the first line<br />
needs to have the four spaces. The others<br />
can be flush left.<br />
<br />
But you can indent all the lines of<br />
a paragraph if you want. That might<br />
be easier to read.<br />
<br />
You can have multiple indent levels:<br />
<br />
This is flush left.<br />
This is indented.<br />
<br />
This is also indented.<br />
And this is indented further.<br />
<br />
To center text, put <code>&gt;&gt;</code> and <code>&lt;&lt;</code> around it.<br />
<br />
>> Centered text <<<br />
<br />
>> Centered paragraph<br />
spanning more than one line. <<<br />
<br />
>> You can mark each <<<br />
>> line separately if you want <<<br />
>> and all lines will be combined <<<br />
>> into one centered paragraph. <<<br />
<br />
Put two spaces after the <code>&lt;&lt;</code> to force a line break within the centered paragraph.<br />
<br />
To right-justify some text, use just <code>&gt;&gt;</code> at the left<br />
<br />
>> Right-justified text<br />
<br />
>> Right-jutified paragraph<br />
spanning multiple lines.<br />
<br />
>> Right-justified paragraphs<br />
>> can have markers on<br />
>> each line.<br />
<br />
=== Lists ===<br />
<br />
You can create numbered, alphabetic, or bullet lists in PGML. Items in a numbered lists begin with a number followed by a period and at least one space.<br />
<br />
1. This is the first item<br />
2. This is the second item<br />
which spans several lines.<br />
<br />
A blank line ends the list, unless it is indented with four spaces, in which case it becomes a new paragraph in the previous numbered item.<br />
<br />
Here is a list:<br />
1. This is the first list item<br />
continued on the next line.<br />
2. Additional items are easy to add.<br />
3. Continuation need not be indented,<br />
such as this line.<br />
<br />
A paragraph break ends the list...<br />
1. Unless you indent the paragraph...<br />
<br />
...in which case it is part of the list item.<br />
2. See?<br />
<br />
Note that the actual numbers used don't matter. PGML will always number from 1 and increment by one each time. So<br />
<br />
1. Item A<br />
2. Item B<br />
3. Item C<br />
<br />
and<br />
<br />
8. Item A<br />
1. Item B<br />
3. Item C<br />
<br />
both produce the same numbered list in the output (numbered as in the first example).<br />
<br />
Alphabetic lists start with a letter followed by a period or a close parenthesis:<br />
<br />
A list with alphabetic markers:<br />
a) You can use dots<br />
b) or parens to indicate the items<br />
<br />
Roman numerals can be obtained using lists starting with roman numbers an a period:<br />
<br />
A list with roman numeral markers:<br />
i. Item 1<br />
ii. Item 2<br />
<br />
Uppercase letters or roman numerals produce lists with upper-case markers.<br />
<br />
Bullet lists begin with an asterisk or a dash. Plus signs produce square bullets, and <code>o</code> produces open circles.<br />
<br />
Bullets:<br />
* Item A<br />
* item B<br />
<br />
Squares:<br />
+ Item A'<br />
+ Item B'<br />
<br />
=== Emphasis ===<br />
<br />
Asterisks are used to indicate '''bold'', and underscores produce ''italics''. (Note: some Markdown processors use <code>*</code> for italics and <code>**</code> for bold; we may adopt that convention in the future.)<br />
<br />
This is *bold text*, and _italic text_.<br />
They can be combined as *_bold italic text_*.<br />
<br />
=== Mathematical Notation ===<br />
<br />
PGML allows you to specify mathematics in two different formats: TeX and calculator notation. The TeX notation allows you to use the standard TeX and LaTeX commands to format your mathematics. The calculator notation uses MathObjects to parse and format the mathematics (so this is the notation that you use to create formulas in your PG problems, and that students use to enter their answers). Both formats come in two forms: in-line and display style. The in-line form uses spacing rules that try to minimize the impact on line spacing, while display style allows for easier readability at the cost of using more vertical space.<br />
<br />
To use TeX-formatted mathematics, enclose it in <code>[`...`]</code> for in-line math and <code>[``...``]</code> for display-style math.<br />
<br />
To use calculator notation, enclose it in <code>[: ... :]</code> for in-line math and <code>[:: ... ::]</code> for display-style math.<br />
<br />
For example, <br />
<br />
What [`x`] makes [`\frac{x+2}{3} = 1`]?<br />
<br />
What [:x:] makes [:(x+2)/3 = 1:]?<br />
<br />
both produce the same results (with in-line math).<br />
<br />
Note that, unlike with TeX, display-mode math is not automatically centered on a separate line. If you want that, you must provide the formatting for that yourself:<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is flush left<br />
<br />
[``\sum_{n=0}^{10} 2^n``] is indented<br />
<br />
>> [``\sum_{n=0}^{10} 2^n ``] is centered <<<br />
<br />
== Interaction with PG ==<br />
<br />
There are two important ways that PGML must interact with the rest of the PG problem: inserting the values of perl variables into the problem (e.g., the randomized parameters for the problem), and making the answer blanks where students will enter their answers and tying those blanks to the correct answers. Both of these are easy to do, and are described below.<br />
<br />
=== Variable Substitution ===<br />
<br />
To insert the value of a variable into your PGML text, enclose the variable name with <code>[...]</code>. For example, if you have a variable <code>$a</code> in your problem, then you can use<br />
<br />
BEGIN_PGML<br />
Suppose that a train leaves Chicago traveling [$a] miles per hour due south.<br />
END_PGML<br />
<br />
Note that a variable that holds a [[:Category:MathObjects|MathObject]] can produce either a TeX string or a calculator-notation string; which one it produces depends on the context in which it is used. If it is inserted inside of TeX math delimiters (e.g., inside <code>[`...`]</code>), it will produce its TeX form, while if it is inserted inside calculator delimiters (e.g., <code>[: ... :]</code>), or not inside any delimiters, then it produces calculator-style notation. So if <code>$f = Formula("(x+1)/(x-1)")</code>, then<br />
<br />
Suppose [`f(x) = [$f]`].<br />
<br />
and<br />
<br />
Suppose [:f(x) = [$f]:].<br />
<br />
will both produce properly formatted mathematical output with no special handling needed on your part. (Note that this is in sharp contrast to the traditional <code>BEGIN_TEXT/END_TEXT</code> approach, which requires you to handle the TeX versions specially.)<br />
<br />
=== Answer Blanks ===<br />
<br />
One of the key ingredients in any WeBWorK problem is answer blanks where students can enter their answers. In PGML, these are created using <code>[_____]</code>, where the number of underscores indicates how wide the answer blank should be. For example<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]<br />
<br />
sets up an answer blank for the student to enter his or her value for <math>x^2</math>. The answer checker for this blank can be provided via <code>ANS()</code> in the traditional way. PGML provides an easier way to tie answers to answer blanks, however. Simply insert the answer inside braces following the answer blank:<br />
<br />
If [: x = [$a] :], then the value of [: x^2 :] is [___________]{$a**2}<br />
<br />
Note that, as in this example, you can use a mathematical expression, or you could use a constant, or a variable. Here, you don't need to enclose the variable in brackets, as this is a perl expression, not PGML text.<br />
<br />
If your answer is a formula, enclose it in quotation marks<br />
<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{"x^2-1"}<br />
<br />
or use a Formula MathObject:<br />
<br />
$f = Compute("x^2-1");<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = 1`] and [`x = -1`]<br />
is [` y = `] [_______________________]{$f}<br />
END_PGML<br />
<br />
If your expression has random parameter, you insert them as you would in a call to the MathObject <code>Compute()</code> command:<br />
<br />
$a = random(2,5,1);<br />
<br />
BEGIN_PGML<br />
The parabola that opens upward and passes through [`x = [$a]`] and [`x = 0`]<br />
is [` y = `] [_______________________]{"x(x-$a)"}<br />
END_PGML<br />
<br />
(Again, no brackets are needed in the answer string).<br />
<br />
If you want to pass parameters to a MathObject answer checker, you can:<br />
<br />
$f = Compute("sqrt(x^2-10)");<br />
<br />
BEGIN_PGML<br />
The answer is [_________________]{$f->cmp(limits=>[4,6])}<br />
END_PGML<br />
<br />
This is just an overview of working with answer blanks. There are other possibilities for what you can pass as the answer, and how you can control the format of the answer blanks. See the documents linked below for more details.<br />
<br />
== Further Reading ==<br />
* '''[[PGML Syntax]]''' -- reference documentation for the various formatting commands<br />
* '''[[PGML Answer Checking]]''' -- reference documentation for answer checking in PGML<br />
<br />
[[Category:PGML]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Variable_substitution_-_PGML&diff=16447Variable substitution - PGML2015-05-10T19:27:41Z<p>Dpvc: Initial version</p>
<hr />
<div>== Variable Substitution ==<br />
<br />
Frequently, you will have computed or randomly generated values that you want to include in the text of your problem. To insert the value of a <code>$a</code> into PGML, use <code>[$a]</code>. Such values can be inserted into the text anywhere, including inside math delimiters.<br />
<br />
Suppose a manufacturer produces [$n] cars at a cost of [$cost] per car.<br />
<br />
or<br />
<br />
Suppose [`f(x) = [$f]`]. Then [`f'(x) = `] [_________________].<br />
<br />
or<br />
<br />
Suppose [: f(x) = [$f] :]. Then [: f'(x) = :] [_________________].<br />
<br />
<br />
In the first example, the values of <code>$a</code> and <code>$cost</code> are inserted as plain text. In the second, example, if <code>$f</code> is a MathObject Formula, then its TeX form will be inserted and processed as TeX code (due to the <code>[`...`]</code> delimiters. In the third example, the Formula object's algebra string will be inserted into the math and processed in the [[Typeset Context]] to generate the mathematical output.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Mathematical_notation_-_PGML&diff=16444Mathematical notation - PGML2015-05-10T19:09:29Z<p>Dpvc: Add information about context selection.</p>
<hr />
<div>__TOC__<br />
== Mathematical Notation ==<br />
<br />
Mathematical notation in PGML can be entered in two different formats: TeX and algebra notation. TeX (or LaTeX) is the format used by most mathematicians to write papers involving mathematics. You can recognize it from its use of backslashes to indicate "commands" and curly braces for grouping. An expression like <code>\sum_{n=1}^\infty a_n</code> is a TeX expression. Algebra notation is the notation used by students to enter their answers, and professors to create MathObjects in the PG problems that they write. You can use whichever form is most convenient for you, and you can even mix the two in the same PGML text block.<br />
<br />
In addition to two types of math input, there are also two forms of math output: in-line and display math. In-line math tries to use as little vertical space as possible so as to not disrupt the line spacing within a paragraph. So things like summation signs will have their limits presented to the right of the sign rather than over top and underneath it, and fractions will use smaller fonts in the numerator and denominator to make the fraction smaller. Display mode, on the other hand, normally is presented on a line by itself, and so more vertical space can be used, so summation limits are shown above and below the summation sign.<br />
<br />
Both input forms give you a way to indication whether you want in-line or displayed math. Note, however, that both forms can be used in-line. If you want your math to be displayed centered on a separate line (as it would be in TeX), you need to use the PGML centering and paragraph formatting to do that. This allows you to format the math the way you want it (flush left, centered, indented, or inline) to suit the problem you are writing.<br />
<br />
=== TeX Notation ===<br />
<br />
To enter math in TeX notation, surround it by <code>[`...`]</code> for in-line math, and <code>[``...``]</code> for display-style math. For example<br />
<br />
This is in-line math: [`\sqrt{b^2-4ac}`], and this math is indented<br />
in display-style, followed by centered math in display-style.<br />
<br />
[``\frac{x+1}{x-1}``]<br />
<br />
>> [``\sum_{n=1}^\infty a_n``] <<<br />
<br />
=== Algebra Notation ===<br />
<br />
To enter math in algebra notation, surround it by <code>[: ... :]</code> for in-line math, and <code>[:: ... ::]</code> for display-style math. For example<br />
<br />
This is in-line math: [: sqrt(b^2-4ac) :], and this math is indented<br />
in display-style, followed by centered math in display-style.<br />
<br />
[:: (x+1)/(x-1) ::]<br />
<br />
>> [:: Sum(n:1,infty; a_n) ::] <<<br />
<br />
The algebra notation uses MathObjects to parse the mathematics for display. By default, it uses a special context called the [[Typeset Context]] that includes many more functions and operators than most other contexts. it is designed to allow you to produce sophisticated mathematical output without the need for TeX, if you prefer a simpler notation.<br />
<br />
If you want to use a different context, however, you can select one by putting its name in braces after the closing bracket for the math delimiters.<br />
<br />
This is in the Vector context: [: <1,2,3> :]{"Vector"}<br />
<br />
You can also provide a Context object instead.<br />
<br />
$context = Context("Vector");<br />
BEGIN_PGML<br />
This is also in Vector context: [: <1,2,3> :]{$context}<br />
END_PGML<br />
<br />
Finally, if you want to use the current context rather than the Typeset context, place an asterisk after the delimiter<br />
<br />
Context("Vector");<br />
BEGIN_PGML<br />
This is also in Vector context: [: <1,2,3> :]*<br />
END_PGML<br />
<br />
== Math and Variable Sibstitution ==<br />
<br />
MathObjects can produce either a TeX version of themselves, or an algebra string version. In the traditional <code>BEGIN_TEXT/END_TEXT</code> block, you must be careful about how you insert a MathObject so as to produce the proper format. This involves either calling the <code>TeX()</code> method of the MathObject, or setting the Context to produce TeX strings automatically. This is awkward and easy to get wrong.<br />
<br />
PGML, on the other hand, knows how you are using your MathObjects, and produces the proper format automatically. If a MathObject is inserted inside TeX delimiters, its TeX form is used, and if inside algebra delimiters (or not in math mode at all), its algebra form is used. So you should not have to worry about inserting MathObjects into PGML -- it should just work.<br />
<br />
$f = Formula("(x+1)/(x-1)");<br />
<br />
BEGIN_PGML<br />
This is TeX: [`` \int [$f]\,dx ``]<br />
<br />
This is algebra: [:: Int(x,[$f]) ::]<br />
<br />
This is text: [$f]<br />
END_PGML<br />
<br />
Here, the fist two should produce properly formatted integrals (one used TeX notation and the other algebra notation). The third one will include <code>(x+1)/(x-1)</code> as a literal algebra string.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Mathematical_notation_-_PGML&diff=16443Mathematical notation - PGML2015-05-10T14:03:22Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== Mathematical Notation ==<br />
<br />
Mathematical notation in PGML can be entered in two different formats: TeX and algebra notation. TeX (or LaTeX) is the format used by most mathematicians to write papers involving mathematics. You can recognize it from its use of backslashes to indicate "commands" and curly braces for grouping. An expression like <code>\sum_{n=1}^\infty a_n</code> is a TeX expression. Algebra notation is the notation used by students to enter their answers, and professors to create MathObjects in the PG problems that they write. You can use whichever form is most convenient for you, and you can even mix the two in the same PGML text block.<br />
<br />
In addition to two types of math input, there are also two forms of math output: in-line and display math. In-line math tries to use as little vertical space as possible so as to not disrupt the line spacing within a paragraph. So things like summation signs will have their limits presented to the right of the sign rather than over top and underneath it, and fractions will use smaller fonts in the numerator and denominator to make the fraction smaller. Display mode, on the other hand, normally is presented on a line by itself, and so more vertical space can be used, so summation limits are shown above and below the summation sign.<br />
<br />
Both input forms give you a way to indication whether you want in-line or displayed math. Note, however, that both forms can be used in-line. If you want your math to be displayed centered on a separate line (as it would be in TeX), you need to use the PGML centering and paragraph formatting to do that. This allows you to format the math the way you want it (flush left, centered, indented, or inline) to suit the problem you are writing.<br />
<br />
=== TeX Notation ===<br />
<br />
To enter math in TeX notation, surround it by <code>[`...`]</code> for in-line math, and <code>[``...``]</code> for display-style math. For example<br />
<br />
This is in-line math: [`\sqrt{b^2-4ac}`], and this math is indented<br />
in display-style, followed by centered math in display-style.<br />
<br />
[``\frac{x+1}{x-1}``]<br />
<br />
>> [``\sum_{n=1}^\infty a_n``] <<<br />
<br />
=== Algebra Notation ===<br />
<br />
To enter math in algebra notation, surround it by <code>[: ... :]</code> for in-line math, and <code>[:: ... ::]</code> for display-style math. For example<br />
<br />
This is in-line math: [: sqrt(b^2-4ac) :], and this math is indented<br />
in display-style, followed by centered math in display-style.<br />
<br />
[:: (x+1)/(x-1) ::]<br />
<br />
>> [:: Sum(n:1,infty; a_n) ::] <<<br />
<br />
== Math and Variable Sibstitution ==<br />
<br />
MathObjects can produce either a TeX version of themselves, or an algebra string version. In the traditional <code>BEGIN_TEXT/END_TEXT</code> block, you must be careful about how you insert a MathObject so as to produce the proper format. This involves either calling the <code>TeX()</code> method of the MathObject, or setting the Context to produce TeX strings automatically. This is awkward and easy to get wrong.<br />
<br />
PGML, on the other hand, knows how you are using your MathObjects, and produces the proper format automatically. If a MathObject is inserted inside TeX delimiters, its TeX form is used, and if inside algebra delimiters (or not in math mode at all), its algebra form is used. So you should not have to worry about inserting MathObjects into PGML -- it should just work.<br />
<br />
$f = Formula("(x+1)/(x-1)");<br />
<br />
BEGIN_PGML<br />
This is TeX: [`` \int [$f]\,dx ``]<br />
<br />
This is algebra: [:: Int(x,[$f]) ::]<br />
<br />
This is text: [$f]<br />
END_PGML<br />
<br />
Here, the fist two should produce properly formatted integrals (one used TeX notation and the other algebra notation). The third one will include <code>(x+1)/(x-1)</code> as a literal algebra string.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Pre-formatted_and_verbatim_text_-_PGML&diff=16439Pre-formatted and verbatim text - PGML2015-05-10T13:11:08Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== Pre-formatted text ==<br />
<br />
Pre-formatted text starts with a colon and three spaces. It will be displayed in a monospaced font, and will respect the line breaks and spacing that you have used. But commands and other markup are still performed within the pre-formatted text as normal.<br />
<br />
: This is preformatted,<br />
: and can include any text, e.g., <, >, $, etc.,<br />
: but [@ "commands" @] and other *mark up* are performed normally.<br />
<br />
Pre-formatted sections can be indented.<br />
<br />
This is flush left.<br />
Here is some indenting<br />
: with pre-formatting<br />
: on several lines.<br />
Now back to normal, but indented.<br />
<br />
== Verbatim text ==<br />
<br />
If you want to prevent commands from being performed and show the characters literally, you use ''verbatim'' mode. Surround the material that should be displayed verbatim with <code>[|...|]</code>.<br />
<br />
If you enter [|*bold*|] in PGML it will be *bold*<br />
<br />
would produce "if you enter *bold* in PGML it will be '''bold'''". Note that verbatim mode is restricted to one line at a time, it can't enclose a line break.<br />
<br />
If you need to include <code>|]</code> within your verbatim section, use ''two'' vertical bars to start and end verbatim mode.<br />
<br />
You can use [|| [|...|] ||] to produce verbatim mode.<br />
<br />
will produce "You can use [|...|] to produce verbatim mode. In fact, you can use as many vertical bars as needed, as long as they are the same number at each end.<br />
<br />
'''Note:''' some flavors of Markdown use back-ticks (<code>`</code>) to enter verbatim mode, but PGML isn't one of them.<br />
<br />
See also [[Special Characters - PGML|Escaping Special Characters]] for how to prevent the interpretation of special characters.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Special_Characters_-_PGML&diff=16438Special Characters - PGML2015-05-10T12:52:43Z<p>Dpvc: Add more escaping details</p>
<hr />
<div>__TOC__<br />
== TeX and HTML Special Characters ==<br />
<br />
In a traditional <code>BEGIN_TEXT/END_TEXT</code>, you have to be careful about using characters that have special meaning in HTML or LaTeX, as using them could cause unwanted results on screen or in hardcopy (and testing in one form didn't mean it would work in the other). These characters are the following:<br />
<br />
<, >, &, %, $, ^, _, #, &, ~, {, }<br />
<br />
With PGML, these characters are handled appropriately regardless of which output method you are using, so there is no need for special treatment. So you can use these characters without fear of adverse repercussions. For example, you can include<br />
<br />
The company "Johnson & Sons" sells a product for $125 a unit.<br />
If their profit is 60% per unit, how many units must they sell<br />
in order to make $1,000 in profits?<br />
<br />
in your problem, and not worry about the special characters that are used. PGML will handle them properly for you.<br />
<br />
== Smart Quotes ==<br />
<br />
PGML will convert the standard single- and double-quote characters to their "smart-quote" versions (ones that differ for opening and closing quotes). You do not need to do anything special to get these smart quotes. So<br />
<br />
Quotes are "smart" ("even here"), and don't forget about 'other' quotes.<br />
<br />
Will produce<br />
<br />
Quotes are “smart” (“even here”), and don’t forget about ‘other’ quotes.<br />
<br />
If you really want the traditional version of the quotes, you can escape the quotes:<br />
<br />
You can escape a quote: \"dumb quotes\".<br />
<br />
== Escaping PGML Special Characters ==<br />
<br />
You can use a backslash to prevent PGML from having their normal effect. So if you want a literal asterisk (rather than bold), you can escape the asterisks.<br />
<br />
This is \*not\* bold.<br />
<br />
Any of the PGML special characters can be treated this way. For example, if a line starts with a 1 and it is also the end of a sentence, that would normally start a numbered list, but you can escape the 1 (to the period after it) to prevent a list for being formed. Here,<br />
<br />
No one can eat just<br />
\1. But 2 is OK.<br />
<br />
the two lines will be joined into one paragraph, whereas<br />
<br />
No one can eat just<br />
1. But 2 is OK<br />
<br />
would form a numbered list with one item ("But 2 is OK") following a paragraph ("No one can eat just").<br />
<br />
Because <code>\</code> is an escape character in PGML, in order to get a litter backslash, you need to escape it, so use ''two'' backslashes.<br />
<br />
This is a literal backslash: \\<br />
<br />
Finally, in the case where an asterisk or brace would be interpreted following a close bracket (e.g., to provide an answer after an answer blank), you can quite the star or brace in order to prevent its usual interpretation and produce a literal asterisk or brace.<br />
<br />
This blank [_____]\{\} is followed by braces that will<br />
appear in the output, and this variable's value [$a]\* will<br />
have a star after it.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Special_Characters_-_PGML&diff=16437Special Characters - PGML2015-05-09T19:04:37Z<p>Dpvc: Initial version</p>
<hr />
<div>__TOC__<br />
== TeX and HTML Special Characters ==<br />
<br />
In a traditional <code>BEGIN_TEXT/END_TEXT</code>, you have to be careful about using characters that have special meaning in HTML or LaTeX, as using them could cause unwanted results on screen or in hardcopy (and testing in one form didn't mean it would work in the other). These characters are the following:<br />
<br />
<, >, &, %, $, ^, _, #, &, ~, {, }<br />
<br />
With PGML, these characters are handled appropriately regardless of which output method you are using, so there is no need for special treatment. So you can use these characters without fear of adverse repercussions. For example, you can include<br />
<br />
The company "Johnson & Sons" sells a product for $125 a unit.<br />
If their profit is 60% per unit, how many units must they sell<br />
in order to make $1,000 in profits?<br />
<br />
in your problem, and not worry about the special characters that are used. PGML will handle them properly for you.<br />
<br />
== Smart Quotes ==<br />
<br />
PGML will convert the standard single- and double-quote characters to their "smart-quote" versions (ones that differ for opening and closing quotes). You do not need to do anything special to get these smart quotes. So<br />
<br />
Quotes are "smart" ("even here"), and don't forget about 'other' quotes.<br />
<br />
Will produce<br />
<br />
Quotes are “smart” (“even here”), and don’t forget about ‘other’ quotes.<br />
<br />
If you really want the traditional version of the quotes, you can escape the quotes:<br />
<br />
You can escape a quote: \"dumb quotes\".<br />
<br />
== Escaping PGML Special Characters ==<br />
<br />
You can use a backslash to prevent PGML from having their normal effect. So if you want a literal asterisk (rather than bold), you can escape the asterisks.<br />
<br />
This is \*not\* bold.<br />
<br />
Any of the PGML special characters can be treated this way. For example, if a line starts with a 1 and it is also the end of a sentence, that would normally start a numbered list, but you can escape the 1 (to the period after it) to prevent a list for being formed. Here,<br />
<br />
No one can eat just<br />
\1. But 2 is OK.<br />
<br />
the two lines will be joined into one paragraph, whereas<br />
<br />
No one can eat just<br />
1. But 2 is OK<br />
<br />
would form a numbered list with one item ("But 2 is OK") following a paragraph ("No one can eat just").<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Rules_-_PGML&diff=16436Rules - PGML2015-05-09T18:33:16Z<p>Dpvc: Initial version</p>
<hr />
<div>== Creating Horizontal Rules ==<br />
<br />
Three or more dashes or equals on a line by itself forms a rule<br />
<br />
-----<br />
<br />
Normally, the rule will extend to fill the horizontal space used by the problem, but<br />
you can specify the width and size (i.e., height) if you want:<br />
<br />
----{200px}<br />
----{50%}<br />
===={200px}{5px}<br />
===={size=>'5px'}<br />
----{width=>'200px',size=>'5px'}<br />
<br />
You can center and right-justify rules:<br />
<br />
>> ----{100px} <<<br />
>> ----{100px}<br />
<br />
They can also be indented.<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvchttps://webwork.maa.org/mediawiki_new/index.php?title=Headings_-_PGML&diff=16435Headings - PGML2015-05-09T18:05:47Z<p>Dpvc: Initial version</p>
<hr />
<div>== Headings in PGML ==<br />
<br />
Heading are indicated by starting a line with hash marks (<code>#</code>). The number of hashes indicates the heading level. A top-level heading has one hash, the secondary headings have two, and so on. There are six levels of heading all together.<br />
<br />
# Heading size 1 #<br />
## Heading size 2 ##<br />
### Heading size 3 ###<br />
#### Heading size 4 ####<br />
##### Heading size 5 #####<br />
###### Heading size 6 ######<br />
<br />
If a heading has several lines in your PG file, they will be combined in the output (and will break according to the space available on screen).<br />
<br />
### Two separate lines ###<br />
### are combined ###<br />
<br />
If you want to force a line break in a heading, put two paces after the hashes where the break is to occur (they are marked as underscores in this example)<br />
<br />
### End with two spaces ###__<br />
### for two lines separately ###<br />
<br />
You can make a whole paragraph be a heading: just put the hashes at the beginning and ending of the paragraph.<br />
<br />
### A whole paragraph<br />
can be a heading ###<br />
<br />
Actually, the trailing hashes are optional<br />
<br />
### The trailing hashes are optional.<br />
<br />
You can combine headings with indenting, centering, and other formatting:<br />
<br />
>> ## centered heading ## <<<br />
>> ## right-justified heading ##<br />
<br />
## indented heading ##<br />
<br />
## non-indented heading ##<br />
<br />
[[Category:PGML]]<br />
[[Category:PGML Syntax]]</div>Dpvc