Documentation
Printing methods and modes
Description
The player's printing functionality works by generating an html code with a simplified, printer-friendly version of the currently loaded lesson. This html can then be used to generate pdf files. After loading a lesson, use the player.preloadAllPages method to ensure that all pages are fully loaded. Optionally, you can also set the lesson state using the player.setState method (see the Display modes section for more details). Once all pages are loaded, you can use the player.getPrintableHTML method to generate the html code.
When displaying the generated html, make sure the available css styles are the same as those in the player's context – failure to do so may result in misalignment of modules or pagination issues. Also, it is recommended to call the getPrintableHTML method in the new player instance. Calling it on an already existing player with a lesson that the user has been interacting with may potentially lead to problems with the printou or interactive lesson.
Supported methods
All of the following methods are called on the player object.
Method name | Params | Description |
---|---|---|
preloadAllPages | callback | This method allows the user to preload all lesson pages. By default, the player uses lazy loading of lesson pages. However, for the getPrintableHTML and getPrintableHTMLWithSeed methods to work are loaded. No arguments will be passed to this method. |
getPrintableHTML | callback, randomizePages, randomizeModules, showAnswers, dpi | This method will pass an html code for the printable version of the current lesson as an argument for the callback function.
|
getPrintableHTMLWithSeed | callback, randomizePages, randomizeModules, showAnswers, dpi, seed | This method works much like getPrintableHTML, except that it allows for explicitly seeding the random number generator used to randomize the pages' order and/or the order of modules on each page via the additional argument seed. |
Display modes
Depending on whether a setState method has been called and the value of the showAnswers argument of the getPrintableHTML method, one of 4 display modes will be used.
Mode | Conditions | Description |
---|---|---|
Empty lesson | setState: no, showAnswers: no |
Printout will display all modules without any answers. |
Show Answers | setState: no, showAnswers: yes |
Printout will display the lesson with all correct answers already selected. |
Completed lesson | setState: yes, showAnswers: no |
Printout will display the answers provided in the lesson state passed through the setState method. |
Check Answers | setState: yes, showAnswers: yes |
Similar to completed lesson, but additionally all user answers will marked as either correct or incorrect. |