ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilAssSelfAssessmentQuestionFormatter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
14  public function format($string)
15  {
16  $string = $this->handleLineBreaks($string);
17 
18  require_once 'Services/RTE/classes/class.ilRTE.php';
19  $string = (string) ilRTE::_replaceMediaObjectImageSrc($string, 1);
20 
21  $string = str_replace("</li><br />", "</li>", $string);
22  $string = str_replace("</li><br>", "</li>", $string);
23 
24  require_once 'Services/Utilities/classes/class.ilUtil.php';
25  $string = ilUtil::insertLatexImages($string, "\[tex\]", "\[\/tex\]");
26  $string = ilUtil::insertLatexImages($string, "<span class\=\"latex\">", "<\/span>");
27 
28  $string = str_replace('{', '&#123;', $string);
29  $string = str_replace('}', '&#125;', $string);
30 
31  return $string;
32  }
33 
38  protected function handleLineBreaks($string)
39  {
40  if( !ilUtil::isHTML($string) )
41  {
42  $string = nl2br($string);
43  }
44 
45  return $string;
46  }
47 }
format($string)
Original code copied from ::formatSAQuestion (author: akill)
static insertLatexImages($a_text, $a_start="\ex\, $a_end="\\tex\")
replace [text]...[/tex] tags with formula image code
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Class ilAssSelfAssessmentQuestionFormatter.
static isHTML($a_text)
Checks if a given string contains HTML or not.