ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssSelfAssessmentQuestionFormatter Class Reference

Class ilAssSelfAssessmentQuestionFormatter. More...

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

Public Member Functions

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

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 54 of file class.ilAssSelfAssessmentQuestionFormatter.php.

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

Referenced by migrateToLmContent().

+ Here is the caller graph for this function:

◆ format()

ilAssSelfAssessmentQuestionFormatter::format (   $string)

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

Parameters
$htmlstring
Returns
string

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

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/Utilities/classes/class.ilUtil.php';
27 $string = ilUtil::insertLatexImages($string, "\[tex\]", "\[\/tex\]");
28 $string = ilUtil::insertLatexImages($string, "<span class\=\"latex\">", "<\/span>");
29
30 $string = str_replace('{', '&#123;', $string);
31 $string = str_replace('}', '&#125;', $string);
32
33 return $string;
34 }
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 insertLatexImages($a_text, $a_start="\[tex\]", $a_end="\[\/tex\]")
replace [text]...[/tex] tags with formula image code

References ilRTE\_replaceMediaObjectImageSrc(), handleLineBreaks(), and ilUtil\insertLatexImages().

+ 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 130 of file class.ilAssSelfAssessmentQuestionFormatter.php.

131 {
132 // set tags we allow in self assessment mode
133 $st = ilUtil::getSecureTags();
134
135 // we allow these tags, since they are typically used in the Tiny Assessment editor
136 // and should not be deleted, if questions are copied from pools to learning modules
137 $not_supported = array("img", "p");
138 $tags = array();
139
141 $tags[] = 'p';
143
144 foreach ($st as $s)
145 {
146 if (!in_array($s, $not_supported))
147 {
148 $tags[] = $s;
149 }
150 }
151
152 return $tags;
153 }
static getSecureTags()

References ilUtil\getSecureTags().

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

+ 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.

41 {
42 if( !ilUtil::isHTML($string) )
43 {
44 $string = nl2br($string);
45 }
46
47 return $string;
48 }
static isHTML($a_text)
Checks if a given string contains HTML or not.

References ilUtil\isHTML().

Referenced by format().

+ 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 111 of file class.ilAssSelfAssessmentQuestionFormatter.php.

112 {
113 $string = $this->convertLatexSpanToTex($string);
114 $string = $this->stripHtmlExceptSelfAssessmentTags($string);
115 return $string;
116 }

References convertLatexSpanToTex(), and stripHtmlExceptSelfAssessmentTags().

+ Here is the call graph for this function:

◆ prepareQuestionForLearningModule()

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

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

122 {
123 $question->migrateContentForLearningModule(new self());
124 }
migrateContentForLearningModule(ilAssSelfAssessmentMigrator $migrator)

References assQuestion\migrateContentForLearningModule().

Referenced by ilPCQuestion\copyPoolQuestionIntoPage().

+ 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 91 of file class.ilAssSelfAssessmentQuestionFormatter.php.

92 {
94
95 $tstr = "";
96
97 foreach ($tags as $t)
98 {
99 $tstr.="<".$t.">";
100 }
101
102 $string = ilUtil::secureString($string, true, $tstr);
103
104 return $string;
105 }
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.

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

Referenced by migrateToLmContent().

+ 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: