ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAssSelfAssessmentQuestionFormatter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilAssSelfAssessmentQuestionFormatter:
+ Collaboration diagram for ilAssSelfAssessmentQuestionFormatter:

Public Member Functions

 format ($string)
 Original code copied from ::formatSAQuestion (author: akill) More...
 
 migrateToLmContent ($string)
 

Static Public Member Functions

static prepareQuestionForLearningModule (assQuestion $question)
 
static getSelfAssessmentTags ()
 Get tags allowed in question tags in self assessment mode. More...
 

Protected Member Functions

 handleLineBreaks ($string)
 
 convertLatexSpanToTex ($string)
 
 stripHtmlExceptSelfAssessmentTags ($string)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilAssSelfAssessmentQuestionFormatter

Definition at line 22 of file class.ilAssSelfAssessmentQuestionFormatter.php.

Member Function Documentation

◆ convertLatexSpanToTex()

ilAssSelfAssessmentQuestionFormatter::convertLatexSpanToTex (   $string)
protected
Parameters
string$string
Returns
string

Definition at line 66 of file class.ilAssSelfAssessmentQuestionFormatter.php.

Referenced by migrateToLmContent().

66  : string
67  {
68  // we try to save all latex tags
69  $try = true;
70  $ls = '<span class="latex">';
71  $le = '</span>';
72  while ($try) {
73  // search position of start tag
74  $pos1 = strpos($string, $ls);
75  if (is_int($pos1)) {
76  $pos2 = strpos($string, $le, $pos1);
77  if (is_int($pos2)) {
78  // both found: replace end tag
79  $string = substr($string, 0, $pos2) . "[/tex]" . substr($string, $pos2 + 7);
80  $string = substr($string, 0, $pos1) . "[tex]" . substr($string, $pos1 + 20);
81  } else {
82  $try = false;
83  }
84  } else {
85  $try = false;
86  }
87  }
88 
89  return $string;
90  }
+ Here is the caller graph for this function:

◆ format()

ilAssSelfAssessmentQuestionFormatter::format (   $string)

Original code copied from ::formatSAQuestion (author: akill)

Parameters
$htmlstring
Returns
string

Definition at line 29 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilRTE\_replaceMediaObjectImageSrc(), ilMathJax\getInstance(), and handleLineBreaks().

29  : string
30  {
31  $string = $this->handleLineBreaks($string);
32 
33  require_once 'Services/RTE/classes/class.ilRTE.php';
34  $string = ilRTE::_replaceMediaObjectImageSrc($string, 1);
35 
36  $string = str_replace("</li><br />", "</li>", $string);
37  $string = str_replace("</li><br>", "</li>", $string);
38 
39  require_once 'Services/MathJax/classes/class.ilMathJax.php';
40  $string = ilMathJax::getInstance()->insertLatexImages($string, "\[tex\]", "\[\/tex\]");
41  $string = ilMathJax::getInstance()->insertLatexImages($string, "<span class\=\"latex\">", "<\/span>");
42 
43  $string = str_replace('{', '&#123;', $string);
44  $string = str_replace('}', '&#125;', $string);
45 
46  return $string;
47  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
+ Here is the call graph for this function:

◆ getSelfAssessmentTags()

static ilAssSelfAssessmentQuestionFormatter::getSelfAssessmentTags ( )
static

Get tags allowed in question tags in self assessment mode.

Returns
array array of tags

Definition at line 134 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\getSecureTags().

Referenced by assClozeTestGUI\addBasicQuestionFormProperties(), assQuestionGUI\addBasicQuestionFormProperties(), ilAssQuestionFeedback\buildFeedbackContentFormProperty(), assLongMenuGUI\populateQuestionSpecificFormPart(), and assClozeTestGUI\populateQuestionSpecificFormPart().

134  : array
135  {
136  // set tags we allow in self assessment mode
137  $st = ilUtil::getSecureTags();
138 
139  $not_supported = ['img'];
140  $tags = ['br', 'table', 'td', 'tr', 'th'] + array_diff($st, $not_supported);
141 
142  return $tags;
143  }
static getSecureTags()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleLineBreaks()

ilAssSelfAssessmentQuestionFormatter::handleLineBreaks (   $string)
protected
Parameters
string$string
Returns
string

Definition at line 53 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\isHTML().

Referenced by format().

53  : string
54  {
55  if (!ilUtil::isHTML($string)) {
56  $string = nl2br($string);
57  }
58 
59  return $string;
60  }
static isHTML(string $a_text)
Checks if a given string contains HTML or not.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migrateToLmContent()

ilAssSelfAssessmentQuestionFormatter::migrateToLmContent (   $string)
Parameters
string$string
Returns
string

Implements ilAssSelfAssessmentMigrator.

Definition at line 115 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References convertLatexSpanToTex(), and stripHtmlExceptSelfAssessmentTags().

115  : string
116  {
117  $string = $this->convertLatexSpanToTex($string);
118  $string = $this->stripHtmlExceptSelfAssessmentTags($string);
119  return $string;
120  }
+ Here is the call graph for this function:

◆ prepareQuestionForLearningModule()

static ilAssSelfAssessmentQuestionFormatter::prepareQuestionForLearningModule ( assQuestion  $question)
static
Parameters
assQuestion$question

Definition at line 125 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References assQuestion\migrateContentForLearningModule().

Referenced by ilPCQuestion\copyPoolQuestionIntoPage().

125  : void
126  {
127  $question->migrateContentForLearningModule(new self());
128  }
migrateContentForLearningModule(ilAssSelfAssessmentMigrator $migrator)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stripHtmlExceptSelfAssessmentTags()

ilAssSelfAssessmentQuestionFormatter::stripHtmlExceptSelfAssessmentTags (   $string)
protected
Parameters
string$string
Returns
string

Definition at line 96 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\secureString().

Referenced by migrateToLmContent().

96  : string
97  {
98  $tags = self::getSelfAssessmentTags();
99 
100  $tstr = "";
101 
102  foreach ($tags as $t) {
103  $tstr .= "<" . $t . ">";
104  }
105 
106  $string = ilUtil::secureString($string, true, $tstr);
107 
108  return $string;
109  }
static secureString(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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