ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssSelfAssessmentQuestionFormatter Class Reference

Class ilAssSelfAssessmentQuestionFormatter. 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

Member Function Documentation

◆ convertLatexSpanToTex()

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

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

Referenced by migrateToLmContent().

54  {
55  // we try to save all latex tags
56  $try = true;
57  $ls = '<span class="latex">';
58  $le = '</span>';
59  while ($try) {
60  // search position of start tag
61  $pos1 = strpos($string, $ls);
62  if (is_int($pos1)) {
63  $pos2 = strpos($string, $le, $pos1);
64  if (is_int($pos2)) {
65  // both found: replace end tag
66  $string = substr($string, 0, $pos2) . "[/tex]" . substr($string, $pos2+7);
67  $string = substr($string, 0, $pos1) . "[tex]" . substr($string, $pos1+20);
68  } else {
69  $try = false;
70  }
71  } else {
72  $try = false;
73  }
74  }
75 
76  return $string;
77  }
+ 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 16 of file class.ilAssSelfAssessmentQuestionFormatter.php.

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

17  {
18  $string = $this->handleLineBreaks($string);
19 
20  require_once 'Services/RTE/classes/class.ilRTE.php';
21  $string = (string) ilRTE::_replaceMediaObjectImageSrc($string, 1);
22 
23  $string = str_replace("</li><br />", "</li>", $string);
24  $string = str_replace("</li><br>", "</li>", $string);
25 
26  require_once 'Services/MathJax/classes/class.ilMathJax.php';
27  $string = ilMathJax::getInstance()->insertLatexImages($string, "\[tex\]", "\[\/tex\]");
28  $string = ilMathJax::getInstance()->insertLatexImages($string, "<span class\=\"latex\">", "<\/span>");
29 
30  $string = str_replace('{', '&#123;', $string);
31  $string = str_replace('}', '&#125;', $string);
32 
33  return $string;
34  }
Add rich text string
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...
static getInstance()
Singleton: get instance.
+ 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

BH 01-03-2018: added P tag to allowed tags due to missing newline problems

BH 01-03-2018: added P tag to allowed tags due to missing newline problems

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

References $s, $tags, array, and ilUtil\getSecureTags().

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

122  {
123  // set tags we allow in self assessment mode
124  $st = ilUtil::getSecureTags();
125 
126  // we allow these tags, since they are typically used in the Tiny Assessment editor
127  // and should not be deleted, if questions are copied from pools to learning modules
128  $not_supported = array("img", "p");
129  $tags = array();
130 
132  $tags[] = 'p';
134 
135  foreach ($st as $s) {
136  if (!in_array($s, $not_supported)) {
137  $tags[] = $s;
138  }
139  }
140 
141  return $tags;
142  }
$s
Definition: pwgen.php:45
static getSecureTags()
$tags
Definition: croninfo.php:19
Create styles array
The data for the language used.
+ 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 40 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References ilUtil\isHTML().

Referenced by format().

41  {
42  if (!ilUtil::isHTML($string)) {
43  $string = nl2br($string);
44  }
45 
46  return $string;
47  }
static isHTML($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 102 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References convertLatexSpanToTex(), and stripHtmlExceptSelfAssessmentTags().

103  {
104  $string = $this->convertLatexSpanToTex($string);
105  $string = $this->stripHtmlExceptSelfAssessmentTags($string);
106  return $string;
107  }
+ Here is the call graph for this function:

◆ prepareQuestionForLearningModule()

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

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

References assQuestion\migrateContentForLearningModule().

Referenced by ilPCQuestion\copyPoolQuestionIntoPage().

113  {
114  $question->migrateContentForLearningModule(new self());
115  }
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 83 of file class.ilAssSelfAssessmentQuestionFormatter.php.

References $t, $tags, and ilUtil\secureString().

Referenced by migrateToLmContent().

84  {
85  $tags = self::getSelfAssessmentTags();
86 
87  $tstr = "";
88 
89  foreach ($tags as $t) {
90  $tstr.="<" . $t . ">";
91  }
92 
93  $string = ilUtil::secureString($string, true, $tstr);
94 
95  return $string;
96  }
$tags
Definition: croninfo.php:19
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
+ 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: