From WeBWorK
Jump to: navigation, search


This code fragment shows how to apply a javascript-enabled popup bit of knowledge (a knowl).

Problem Techniques Index

PG problem file Explanation
Here is a knowl
\{ knowlLink("click me",
value=>'This is the inside of a knowl.  ' .
'If you click again, I will go away') \}

Here is another knowl
\{ knowlLink("click me", 
url=>'url_of_file_with_information') \}

knowlLink("a math knowl",
value=>escapeSolutionHTML(EV3P("the sine function is \\(\\sin(x)\\)")), base64=>1);

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,

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.

Templates by Subject Area

Problem Techniques Index

follow us