ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 60 of file class.ilAssSelfAssessmentQuestionFormatter.php.

Referenced by migrateToLmContent().

60  : string
61  {
62  // we try to save all latex tags
63  $try = true;
64  $ls = '<span class="latex">';
65  $le = '</span>';
66  while ($try) {
67  // search position of start tag
68  $pos1 = strpos($string, $ls);
69  if (is_int($pos1)) {
70  $pos2 = strpos($string, $le, $pos1);
71  if (is_int($pos2)) {
72  // both found: replace end tag
73  $string = substr($string, 0, $pos2) . "[/tex]" . substr($string, $pos2 + 7);
74  $string = substr($string, 0, $pos1) . "[tex]" . substr($string, $pos1 + 20);
75  } else {
76  $try = false;
77  }
78  } else {
79  $try = false;
80  }
81  }
82 
83  return $string;
84  }
+ 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  $string = ilRTE::_replaceMediaObjectImageSrc($string, 1);
33  $string = str_replace("</li><br />", "</li>", $string);
34  $string = str_replace("</li><br>", "</li>", $string);
35  $string = ilMathJax::getInstance()->insertLatexImages($string, "\[tex\]", "\[\/tex\]");
36  $string = ilMathJax::getInstance()->insertLatexImages($string, "<span class\=\"latex\">", "<\/span>");
37  $string = str_replace('{', '&#123;', $string);
38  $string = str_replace('}', '&#125;', $string);
39 
40  return $string;
41  }
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 128 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\getSecureTags().

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

128  : array
129  {
130  // set tags we allow in self assessment mode
131  $st = ilUtil::getSecureTags();
132 
133  $not_supported = ['img'];
134  $tags = ['br', 'table', 'td', 'tr', 'th'] + array_diff($st, $not_supported);
135 
136  return $tags;
137  }
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 47 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\isHTML().

Referenced by format().

47  : string
48  {
49  if (!ilUtil::isHTML($string)) {
50  $string = nl2br($string);
51  }
52 
53  return $string;
54  }
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 109 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References convertLatexSpanToTex(), and stripHtmlExceptSelfAssessmentTags().

109  : string
110  {
111  $string = $this->convertLatexSpanToTex($string);
112  $string = $this->stripHtmlExceptSelfAssessmentTags($string);
113  return $string;
114  }
+ Here is the call graph for this function:

◆ prepareQuestionForLearningModule()

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

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

References assQuestion\migrateContentForLearningModule().

Referenced by ilPCQuestion\copyPoolQuestionIntoPage().

119  : void
120  {
121  $question->migrateContentForLearningModule(new self());
122  }
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 90 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\secureString().

Referenced by migrateToLmContent().

90  : string
91  {
92  $tags = self::getSelfAssessmentTags();
93 
94  $tstr = "";
95 
96  foreach ($tags as $t) {
97  $tstr .= "<" . $t . ">";
98  }
99 
100  $string = ilUtil::secureString($string, true, $tstr);
101 
102  return $string;
103  }
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: