Once you have installed the offline quiz plugin
Go to the plugin directory: https://yoursite/moodle/mod/offlinequiz
Here you will have to modify the following files (for generating different formats of your quiz).
- locallib.php
- pdflib.php
- docxlib.php
I edited 1st and 2nd as I did not need DOCx.
In locallib.php, you will have to make changes to the offlinequiz_print_question_preview method
In pdflib.php, you will modify offlinequiz_create_pdf_question method
For locallib.php, follow the following steps:
1. Include the filter file
- moodle/filter/wiris/filter.php
2. Add the filter to your array of filters that are already applied
$filters = filter_get_active_in_context($context);3. And then apply the wiris filter to your data:
if (array_key_exists('wiris', $filters)) {
$wirisfilter = new filter_wiris($context, array());
}
if ($wirisfilter) {
$text = $wirisfilter->filter($text);
if ($question->qtype != 'description') {
foreach ($choiceorder as $key => $answer) {
$question->options->answers[$answer]->answer = $wirisfilter->filter($question->options->answers[$answer]->answer);
}
}
}
For pdflib.php:
1. Include the filter file as you did above.
2. Create a new wirisfilter variable:
$wirisfilter = new filter_wiris($context, array());
$pdf->checkpoint();We added this to our question text only. We still need to apply to the answers/options yet.
$questiontext = $question->questiontext;
if (!empty($texfilter)) {
$questiontext = $texfilter->filter($questiontext);
}
//Add this filter. The above code will be already be there.
if (!empty($wirisfilter)) {
$questiontext = $wirisfilter->filter($questiontext);
}
4. Find the foreach loop (shown below) and add the filter to answers/choices
foreach ($order as $key => $answer) {5. Wherever you find any other filter (in my case 'texfilter') already applied in your code, include the wirisfilter there.
//Add this filter code inside the loop
if (!empty($wirisfilter)) {
$answertext = $wirisfilter->filter($answertext);
}
These are all the steps I followed to get the rendering proper.
Regards,
Mohanish