ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestPDFGenerator Class Reference

Class ilTestPDFGenerator. More...

+ Collaboration diagram for ilTestPDFGenerator:

Static Public Member Functions

static generatePDF ($pdf_output, $output_mode, $filename=null)
static preprocessHTML ($html)

Data Fields

const PDF_OUTPUT_DOWNLOAD = 'D'
const PDF_OUTPUT_INLINE = 'I'
const PDF_OUTPUT_FILE = 'F'

Static Protected Member Functions

static getTemplatePath ($a_filename)

Static Private Member Functions

static removeScriptElements ($html)

Detailed Description

Class ilTestPDFGenerator.

Class that handles PDF generation for test and assessment.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 13 of file class.ilTestPDFGenerator.php.

Member Function Documentation

static ilTestPDFGenerator::generatePDF (   $pdf_output,
  $output_mode,
  $filename = null 
)
static

Definition at line 59 of file class.ilTestPDFGenerator.php.

References $filename, ilPDFGeneration\doJob(), and preprocessHTML().

Referenced by ilTestPlayerAbstractGUI\archiveParticipantSubmission(), ilObjTestGUI\createUserResults(), ilTestServiceGUI\getQuestionResultForTestUsers(), ilTestEvaluationGUI\outParticipantsPassDetails(), ilTestEvaluationGUI\outParticipantsResultsOverview(), ilTestEvaluationGUI\outUserPassDetails(), ilTestEvaluationGUI\outUserResultsOverview(), ilObjTestGUI\printobject(), ilTestScoring\recalculatePasses(), ilTestSubmissionReviewGUI\show(), and ilTestArchiver\updateTestArchive().

{
$pdf_output = self::preprocessHTML($pdf_output);
if (substr($filename, strlen($filename) - 4, 4) != '.pdf')
{
$filename .= '.pdf';
}
require_once './Services/PDFGeneration/classes/class.ilPDFGeneration.php';
$job = new ilPDFGenerationJob();
$job->setAutoPageBreak(true)
->setCreator('ILIAS Test')
->setFilename($filename)
->setMarginLeft('20')
->setMarginRight('20')
->setMarginTop('20')
->setMarginBottom('20')
->setOutputMode($output_mode)
->addPage($pdf_output);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilTestPDFGenerator::getTemplatePath (   $a_filename)
staticprotected

Definition at line 91 of file class.ilTestPDFGenerator.php.

Referenced by preprocessHTML().

{
$module_path = "Modules/Test/";
// use ilStyleDefinition instead of account to get the current skin
include_once "Services/Style/classes/class.ilStyleDefinition.php";
if (ilStyleDefinition::getCurrentSkin() != "default")
{
$fname = "./Customizing/global/skin/".
ilStyleDefinition::getCurrentSkin()."/".$module_path.basename($a_filename);
}
if($fname == "" || !file_exists($fname))
{
$fname = "./".$module_path."templates/default/".basename($a_filename);
}
return $fname;
}

+ Here is the caller graph for this function:

static ilTestPDFGenerator::preprocessHTML (   $html)
static

Definition at line 84 of file class.ilTestPDFGenerator.php.

References getTemplatePath(), and removeScriptElements().

Referenced by generatePDF().

{
$pdf_css_path = self::getTemplatePath('test_pdf.css');
return '<style>' . file_get_contents($pdf_css_path) . '</style>' . $html;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilTestPDFGenerator::removeScriptElements (   $html)
staticprivate
Parameters
$html
Returns
string

Definition at line 23 of file class.ilTestPDFGenerator.php.

Referenced by preprocessHTML().

{
if(!is_string($html) || !strlen(trim($html)))
{
return $html;
}
$dom = new DOMDocument("1.0", "utf-8");
if(!@$dom->loadHTML('<?xml encoding="UTF-8">' . $html))
{
return $html;
}
$invalid_elements = array();
$script_elements = $dom->getElementsByTagName('script');
foreach($script_elements as $elm)
{
$invalid_elements[] = $elm;
}
foreach($invalid_elements as $elm)
{
$elm->parentNode->removeChild($elm);
}
$dom->encoding = 'UTF-8';
$cleaned_html = $dom->saveHTML();
if(!$cleaned_html)
{
return $html;
}
return $cleaned_html;
}

+ Here is the caller graph for this function:

Field Documentation

const ilTestPDFGenerator::PDF_OUTPUT_INLINE = 'I'

Definition at line 16 of file class.ilTestPDFGenerator.php.


The documentation for this class was generated from the following file: