Difference between revisions of "Knowls"
Jump to navigation
Jump to search
(added historical tag and gave updated problem link) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | <h2>Knowls</h2> |
||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/Knowls.html a newer version of this problem]</p><h2>Knowls</h2> |
||
<!-- Header for these sections -- no modification needed --> |
<!-- Header for these sections -- no modification needed --> |
||
Line 28: | Line 30: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | |||
+ | BEGIN_TEXT |
||
$PAR |
$PAR |
||
Here is a knowl |
Here is a knowl |
||
− | \{ knowlLink("click me", value=>'This is the inside of a knowl. If you click again, I will go away') \} |
||
+ | \{ knowlLink("click me", |
||
− | $PAR |
||
+ | value=>'This is the inside of a knowl. ' . |
||
+ | 'If you click again, I will go away') \} |
||
$PAR |
$PAR |
||
Here is another knowl |
Here is another knowl |
||
− | \{ knowlLink("click me", |
+ | \{ knowlLink("click me", |
+ | url=>'url_of_file_with_information') \} |
||
+ | |||
$PAR |
$PAR |
||
− | |||
+ | \{ |
||
+ | knowlLink("a math knowl", |
||
+ | value=>escapeSolutionHTML(EV3P("the sine function is \\(\\sin(x)\\)")), base64=>1); |
||
+ | \} |
||
+ | END_TEXT |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 44: | Line 51: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | |||
+ | 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. |
||
− | Instead of specifying a value, you can specify the url of a file with html in it, and that html will appear in the knowl. Then you can use one file in multiple places. |
||
+ | </p> |
||
− | |||
+ | <p> |
||
+ | 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. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 53: | Line 61: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | return knowlLink($display_text, |
+ | return knowlLink($display_text, |
+ | url=>$envir{'localHelpURL'}.$infoRef); |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 59: | Line 67: | ||
As another example, here is the last line of the definition of helpLink() where the knowl |
As another example, here is the last line of the definition of helpLink() where the knowl |
||
containing the help message is created after defining the variables which contain the url for the help file. |
containing the help message is created after defining the variables which contain the url for the help file. |
||
− | |||
− | Knowls can include variables from earlier in the problem. |
||
− | |||
− | Use knowlLink("link text",escapeSolutionHTML(EV3P("your text with math using standard form)"))); |
||
− | |||
− | The escapeSolutionHTML and EV3P are needed to get the math to be handled properly. |
||
</td> |
</td> |
||
</tr> |
</tr> |
Latest revision as of 10:41, 29 June 2023
This problem has been replaced with a newer version of this problem
Knowls
This code fragment shows how to apply a javascript-enabled popup bit of knowledge (a knowl).
PG problem file | Explanation |
---|---|
BEGIN_TEXT $PAR Here is a knowl \{ knowlLink("click me", value=>'This is the inside of a knowl. ' . 'If you click again, I will go away') \} $PAR Here is another knowl \{ knowlLink("click me", url=>'url_of_file_with_information') \} $PAR \{ knowlLink("a math knowl", value=>escapeSolutionHTML(EV3P("the sine function is \\(\\sin(x)\\)")), base64=>1); \} END_TEXT |
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. 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. |
return knowlLink($display_text, url=>$envir{'localHelpURL'}.$infoRef); |
As another example, here is the last line of the definition of helpLink() where the knowl containing the help message is created after defining the variables which contain the url for the help file. |