Example #1
0
 function make_formula($text)
 {
     if (self::$latex->is_available()) {
         return self::$latex->make_image('$' . trim($text) . '$');
     }
     $text = '<m>' . $text . '</m>';
     $size = 10;
     $pathtoimg = 'images/formulas/';
     return mathfilter($text, $size, $pathtoimg);
 }
 /**
  * Return a string, after replacing Latex math sections with n image equivelant.
  *
  * @param   string  $text
  * @return  string
  */
 public static function transform($text)
 {
     if (trim($text) === '') {
         return $text;
     }
     // relative from the sf_web_root
     $dir = sfConfig::get('app_rt_math_cache_dir', '/uploads/_math_cache');
     $size = sfConfig::get('app_rt_math_mathpublisher_size', 14);
     if (!is_dir(sfConfig::get('sf_web_dir') . $dir)) {
         rtAssetToolkit::makeDir(sfConfig::get('sf_web_dir') . $dir);
     }
     $dir = $dir . '/';
     try {
         $text = mathfilter($text, $size, $dir);
     } catch (Exception $e) {
         // eat the exception
     }
     return $text;
 }
Example #3
0
/**
 * @brief display course description resource
 * @global string $tool_content
 * @param type $title
 * @param type $comments
 * @param type $id
 * @param type $res_id
 * @param type $visibility
 */
function show_description($title, $comments, $id, $res_id, $visibility)
{
    global $tool_content;
    $comments = mathfilter($comments, 12, "../../courses/mathimg/");
    $tool_content .= "\n        <tr>\n          <td colspan='2'>\n            <div class='title'>" . q($title) . "</div>\n            <div class='content'>{$comments}</div>\n          </td>" . actions('description', $id, $visibility, $res_id) . "\n        </tr>";
}
<input type="text" name="size" size="2" value="<? echo $HTTP_GET_VARS['size']; ?>">
&nbsp;&nbsp;
<SELECT NAME="choix" onChange="choisir(this.selectedIndex)">
<OPTION >Exemples
<OPTION >Exemple 1
<OPTION >Exemple 2
<OPTION >Exemple 3
</SELECT>
&nbsp;&nbsp;<input type="submit" name="bouton" value="Afficher">
</p>
</form>
</div>
<div id="contentlabel">Résultat</div>
<?
include("../mathpublisher.php") ;
$message=$HTTP_GET_VARS['message'];
$size=$HTTP_GET_VARS['size'];
if ((!isset($size)) || $size<10) $size=14;
if ( isset($message) && $message!='' ) 
	{
	echo("<div style=\"font-family : 'Times New Roman',times,serif ; font-size :{$size}pt;\">".mathfilter($message,$size,"../img/")."</div>");
	}
?>
<div id="footer">
<p><A href="http://www.xm1math.net/phpmathpublisher/index_fr.html">PhpMathPublisher</A> - Copyright 2005 <b>Pascal Brachet - France</b> <br>
L'auteur est professeur de mathématiques au lycée Bernard Palissy à Agen.<br>
Ce programme est distribué selon les termes de la licence libre GPL.</p>
</div>
</body>
</html>
Example #5
0
 /**
  * display action details in abuse reports
  * @global type $langcreator
  * @global type $langAbuseReportCat
  * @global type $langSpam
  * @global type $langRudeness
  * @global type $langOther
  * @global type $langMessage
  * @global type $langComment
  * @global type $langForumPost
  * @global type $langAbuseResourceType
  * @global type $langContent
  * @global type $langAbuseReportStatus
  * @global type $langAbuseReportOpen
  * @global type $langAbuseReportClosed
  * @param type $details
  * @return string
  */
 private function abuse_report_action_details($details)
 {
     global $langcreator, $langAbuseReportCat, $langSpam, $langRudeness, $langOther, $langMessage, $langComment, $langForumPost, $langAbuseResourceType, $langContent, $langAbuseReportStatus, $langAbuseReportOpen, $langAbuseReportClosed, $langLinks;
     $reports_cats = array('rudeness' => $langRudeness, 'spam' => $langSpam, 'other' => $langOther);
     $resource_types = array('comment' => $langComment, 'forum_post' => $langForumPost, 'link' => $langLinks);
     $details = unserialize($details);
     $content = "{$langcreator}: " . display_user($details['user_id'], false, false) . "<br/>";
     $content .= "{$langAbuseReportCat}: &laquo" . $reports_cats[$details['reason']] . "&raquo<br/>";
     $content .= "{$langMessage}: &laquo" . q($details['message']) . "&raquo<br/>";
     $content .= "{$langAbuseResourceType}: &laquo" . $resource_types[$details['rtype']] . "&raquo<br/>";
     if ($details['rtype'] == 'comment') {
         $content .= "{$langContent}: &laquo" . q($details['rcontent']) . "&raquo<br/>";
     } elseif ($details['rtype'] == 'forum_post') {
         $content .= "{$langContent}: &laquo" . mathfilter($details['rcontent'], 12, "../courses/mathimg/") . "&raquo<br/>";
     }
     if ($details['status'] == 1) {
         $content .= "{$langAbuseReportStatus}: &laquo" . $langAbuseReportOpen . "&raquo";
     } elseif ($details['status'] == 0) {
         $content .= "{$langAbuseReportStatus}: &laquo" . $langAbuseReportClosed . "&raquo";
     }
     return $content;
 }
Example #6
0
function showQuestion(&$objQuestionTmp, $exerciseResult = array())
{
    global $tool_content, $picturePath, $langNoAnswer, $langQuestion, $langColumnA, $langColumnB, $langMakeCorrespond, $langInfoGrades, $i, $exerciseType, $nbrQuestions, $langInfoGrade;
    $questionId = $objQuestionTmp->id;
    $questionWeight = $objQuestionTmp->selectWeighting();
    $answerType = $objQuestionTmp->selectType();
    $message = $langInfoGrades;
    if (intval($questionWeight) == $questionWeight) {
        $questionWeight = intval($questionWeight);
    }
    if ($questionWeight == 1) {
        $message = $langInfoGrade;
    }
    $questionName = $objQuestionTmp->selectTitle();
    $questionDescription = $objQuestionTmp->selectDescription();
    $questionDescription_temp = $questionDescription;
    $questionTypeWord = $objQuestionTmp->selectTypeWord($answerType);
    $tool_content .= "\n            <div class='panel panel-success'>\n              <div class='panel-heading'>\n                <h3 class='panel-title'>{$langQuestion} : {$i} ({$questionWeight} {$message})" . ($exerciseType == 2 ? " / " . $nbrQuestions : "") . "</h3>\n              </div>\n              <div class='panel-body'>\n                    <h4>{$questionName} <br> \n                        <small>{$questionTypeWord}</small>\n                    </h4>\n                    {$questionDescription_temp}\n                    <div class='text-center'>\n                        " . (file_exists($picturePath . '/quiz-' . $questionId) ? "<img src='../../{$picturePath}/quiz-{$questionId}'>" : "") . "\n                    </div>";
    // construction of the Answer object
    $objAnswerTmp = new Answer($questionId);
    $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
    if ($answerType == FREE_TEXT) {
        $text = isset($exerciseResult[$questionId]) ? $exerciseResult[$questionId] : '';
        $tool_content .= rich_text_editor('choice[' . $questionId . ']', 14, 90, $text);
    }
    if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == TRUE_FALSE) {
        $tool_content .= "<input type='hidden' name='choice[{$questionId}]' value='0' />";
    }
    // only used for the answer type "Matching"
    if ($answerType == MATCHING && $nbrAnswers > 0) {
        $cpt1 = 'A';
        $cpt2 = 1;
        $Select = array();
        $tool_content .= "\n                      <table class='table-default'>\n                      <tr>\n                        <th>{$langColumnA}</th>\n                        <th>{$langMakeCorrespond}</th>\n                        <th>{$langColumnB}</th>\n                      </tr>";
    }
    if ($answerType == FILL_IN_BLANKS) {
        $tool_content .= "<div class='form-inline'>";
    }
    for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
        $answer = $objAnswerTmp->selectAnswer($answerId);
        $answer = mathfilter($answer, 12, '../../courses/mathimg/');
        $answerCorrect = $objAnswerTmp->isCorrect($answerId);
        if ($answerType == FILL_IN_BLANKS) {
            // splits text and weightings that are joined with the character '::'
            list($answer) = explode('::', $answer);
            // replaces [blank] by an input field
            $replace_callback = function () use($questionId, $exerciseResult) {
                static $id = 0;
                $id++;
                $value = isset($exerciseResult[$questionId][$id]) ? 'value = ' . $exerciseResult[$questionId][$id] : '';
                return "<input type='text' name='choice[{$questionId}][{$id}]' {$value}>";
            };
            $answer = preg_replace_callback('/\\[[^]]+\\]/', $replace_callback, standard_text_escape($answer));
        }
        // unique answer
        if ($answerType == UNIQUE_ANSWER) {
            $checked = isset($exerciseResult[$questionId]) && $exerciseResult[$questionId] == $answerId ? 'checked="checked"' : '';
            $tool_content .= "\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' name='choice[{$questionId}]' value='{$answerId}' {$checked}>\n                            " . standard_text_escape($answer) . "\n                          </label>\n                        </div>";
        } elseif ($answerType == MULTIPLE_ANSWER) {
            $checked = isset($exerciseResult[$questionId][$answerId]) && $exerciseResult[$questionId][$answerId] == 1 ? 'checked="checked"' : '';
            $tool_content .= "\n                        <div class='checkbox'>\n                          <label>\n                            <input type='checkbox' name='choice[{$questionId}][{$answerId}]' value='1' {$checked}>\n                            " . standard_text_escape($answer) . "\n                          </label>\n                        </div>";
        } elseif ($answerType == FILL_IN_BLANKS) {
            $tool_content .= $answer;
        } elseif ($answerType == MATCHING) {
            if (!$answerCorrect) {
                // options (A, B, C, ...) that will be put into the list-box
                $Select[$answerId]['Lettre'] = $cpt1++;
                // answers that will be shown at the right side
                $Select[$answerId]['Reponse'] = standard_text_escape($answer);
            } else {
                $tool_content .= "\n\t\t\t\t    <tr>\n\t\t\t\t      <td><b>{$cpt2}.</b> " . standard_text_escape($answer) . "</td>\n\t\t\t\t      <td><div align='left'>\n\t\t\t\t       <select name='choice[{$questionId}][{$answerId}]'>\n\t\t\t\t\t <option value='0'>--</option>";
                // fills the list-box
                foreach ($Select as $key => $val) {
                    $selected = isset($exerciseResult[$questionId][$answerId]) && $exerciseResult[$questionId][$answerId] == $key ? 'selected="selected"' : '';
                    $tool_content .= "\n\t\t\t\t\t<option value=\"" . q($key) . "\" {$selected}>{$val['Lettre']}</option>";
                }
                $tool_content .= "</select></div></td><td width='200'>";
                if (isset($Select[$cpt2])) {
                    $tool_content .= '<b>' . q($Select[$cpt2]['Lettre']) . '.</b> ' . $Select[$cpt2]['Reponse'];
                } else {
                    $tool_content .= '&nbsp;';
                }
                $tool_content .= "</td></tr>";
                $cpt2++;
                // if the left side of the "matching" has been completely shown
                if ($answerId == $nbrAnswers) {
                    // if it remains answers to shown at the right side
                    while (isset($Select[$cpt2])) {
                        $tool_content .= "\n                                              <tr class='even'>\n                                                <td colspan='2'>\n                                                  <table width='100%'>\n                                                  <tr>\n                                                  <td width='200'>&nbsp;</td>\n                                                  <td width='100'>&nbsp;</td>\n                                                  <td width='200' valign='top'>" . "<b>" . q($Select[$cpt2]['Lettre']) . ".</b> " . q($Select[$cpt2]['Reponse']) . "\n                                                  </td>\n                                                  </tr>\n                                                  </table>\n                                                </td>\n                                              </tr>";
                        $cpt2++;
                    }
                    // end while()
                }
                // end if()
            }
        } elseif ($answerType == TRUE_FALSE) {
            $checked = isset($exerciseResult[$questionId]) && $exerciseResult[$questionId] == $answerId ? 'checked="checked"' : '';
            $tool_content .= "\n                        <div class='radio'>\n                          <label>\n                            <input type='radio' name='choice[{$questionId}]' value='{$answerId}' {$checked}>\n                            " . standard_text_escape($answer) . "\n                          </label>\n                        </div>";
        }
    }
    // end for()
    if ($answerType == MATCHING && $nbrAnswers > 0) {
        $tool_content .= "</table>";
    }
    if ($answerType == FILL_IN_BLANKS) {
        $tool_content .= "</div>";
    }
    if (!$nbrAnswers && $answerType != FREE_TEXT) {
        $tool_content .= "<div class='alert alert-danger'>{$langNoAnswer}</div>";
    }
    $tool_content .= "          \n                </div>\n            </div>";
    // destruction of the Answer object
    unset($objAnswerTmp);
    // destruction of the Question object
    unset($objQuestionTmp);
    return $nbrAnswers;
}
&nbsp;&nbsp;<input type="submit" name="bouton" value="Convertir">
</p>
</form>
</div>
<div id="contentlabel">Résultat</div>
<div id="contentbox"><p>Ici s'affiche le code html généré par PhpMathPublisher.</p></div>
<div align="left">
<form name="forme2">
<TEXTAREA NAME="resultat" COLS="80" ROWS="10">
<?
include("../mathpublisher.php") ;
$message=$HTTP_GET_VARS['message'];
$size=$HTTP_GET_VARS['size'];
$pathtoimg=$HTTP_GET_VARS['pathtoimg'];
if (!isset($pathtoimg)) $pathtoimg="img/";
if ((!isset($size)) || $size<10) $size=14;
if ( isset($message) && $message!='' ) 
	{
	echo(mathfilter($message,$size,$pathtoimg));
	}
?>
</TEXTAREA>
</div>
<div id="footer">
<p><A href="http://www.xm1math.net/phpmathpublisher/index_fr.html">PhpMathPublisher</A> - Copyright 2005 <b>Pascal Brachet - France</b> <br>
L'auteur est professeur de mathématiques au lycée Bernard Palissy à Agen.<br>
Ce programme est distribué selon les termes de la licence libre GPL.</p>
</div>
</body>
</html>
Example #8
0
        if ($valeur == $_POST['taille']) {
            echo ' selected="selected"';
        }
        echo ">{$valeur}</option>\n";
    }
    echo "</select></li>";
    echo '<li>V&#233;rifier l\'image de la formule car elle n\'est plus modifiable lorsqu\'elle est valid&#233;e<br />';
    echo '<input type="submit" class="bt" name="Previsualiser" value="Pr&#233;visualiser" />';
    if (isset($_POST['Previsualiser'])) {
        echo '<div id="eqt">';
        include "../phpmathpublisher/mathpublisher.php";
        $message = "<m>" . $equation . "</m>";
        $size = $_POST['taille'];
        $pathtoimg = '../phpmathpublisher/img/';
        if (isset($equation) && $equation != '') {
            $retour = mathfilter($message, $size, $pathtoimg);
            echo "&nbsp;" . $retour;
        }
        echo '</div></li>';
    }
    echo '<li>Indiquer le sous-r&#233;pertoire de votre "public_html" dans lequel sera enregistr&#233;e l\'image :   s\'il n\'existe pas, il sera cr&#233;&#233; <br /><input class="text" type="text" name="sousrep" value="Images_Cdt" size="30" /></li>';
    echo '<li>Le bouton <b> Valider </b> transf&#232;re l\'image sur le serveur et ins&#232;re automatiquement le lien</li>';
    echo '</ol>';
    echo '<input type="submit" name="Valider" value="Valider" class="bt" />';
}
?>
</fieldset>
    </div>
</form>
<?php 
include '../Includes/pied.inc';
Example #9
0
function showQuestion($questionId, $onlyAnswers = false)
{
    global $picturePath, $urlServer;
    global $langNoAnswer, $langColumnA, $langColumnB, $langMakeCorrespond;
    // construction of the Question object
    $objQuestionTmp = new Question();
    // reads question informations
    if (!$objQuestionTmp->read($questionId)) {
        // question not found
        return false;
    }
    $answerType = $objQuestionTmp->selectType();
    if (!$onlyAnswers) {
        $questionName = $objQuestionTmp->selectTitle();
        $questionDescription = $objQuestionTmp->selectDescription();
        $questionDescription_temp = standard_text_escape($questionDescription);
        echo "<tr class='even'>\n                    <td colspan='2'><b>" . q($questionName) . "</b><br />\n                    {$questionDescription_temp}\n                    </td>\n                    </tr>";
        if (file_exists($picturePath . '/quiz-' . $questionId)) {
            echo "<tr class='even'>\n                        <td class='center' colspan='2'><img src='{$urlServer}/{$picturePath}/quiz-{$questionId}' /></td>\n                      </tr>";
        }
    }
    // end if(!$onlyAnswers)
    // construction of the Answer object
    $objAnswerTmp = new Answer($questionId);
    $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
    // only used for the answer type "Matching"
    if ($answerType == MATCHING) {
        $cpt1 = 'A';
        $cpt2 = 1;
        $select = array();
        echo "\n              <tr class='even'>\n                <td colspan='2'>\n                  <table class='tbl_border' width='100%'>\n                  <tr>\n                    <th width='200'>{$langColumnA}</th>\n                    <th width='130'>{$langMakeCorrespond}</th>\n                    <th width='200'>{$langColumnB}</th>\n                  </tr>\n                  </table>\n                </td>\n              </tr>";
    }
    for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
        $answer = $objAnswerTmp->selectAnswer($answerId);
        $answer = mathfilter($answer, 12, '../../courses/mathimg/');
        $answerCorrect = $objAnswerTmp->isCorrect($answerId);
        if ($answerType == FILL_IN_BLANKS) {
            // splits text and weightings that are joined with the character '::'
            list($answer) = explode('::', $answer);
            // replaces [blank] by an input field
            $answer = preg_replace('/\\[[^]]+\\]/', '<input type="text" name="choice[' . $questionId . '][]" size="10" />', standard_text_escape($answer));
        }
        // unique answer
        if ($answerType == UNIQUE_ANSWER) {
            echo "\n                      <tr class='even'>\n                        <td class='center' width='1'>\n                          <input type='radio' name='choice[{$questionId}]' value='{$answerId}' />\n                        </td>\n                        <td>" . standard_text_escape($answer) . "</td>\n                      </tr>";
        } elseif ($answerType == MULTIPLE_ANSWER) {
            echo "\n                      <tr class='even'>\n                        <td width='1' align='center'>\n                          <input type='checkbox' name='choice[{$questionId}][{$answerId}]' value='1' />\n                        </td>\n                        <td>" . standard_text_escape($answer) . "</td>\n                      </tr>";
        } elseif ($answerType == FILL_IN_BLANKS) {
            echo "\n                      <tr class='even'>\n                        <td colspan='2'>" . $answer . "</td>\n                      </tr>";
        } elseif ($answerType == MATCHING) {
            if (!$answerCorrect) {
                // options (A, B, C, ...) that will be put into the list-box
                $select[$answerId]['Lettre'] = $cpt1++;
                // answers that will be shown at the right side
                $select[$answerId]['Reponse'] = standard_text_escape($answer);
            } else {
                echo "<tr class='even'>\n                                <td colspan='2'>\n                                  <table class='tbl'>\n                                  <tr>\n                                    <td width='200'><b>{$cpt2}.</b> " . standard_text_escape($answer) . "</td>\n                                    <td width='130'><div align='center'>\n                                     <select name='choice[{$questionId}][{$answerId}]'>\n                                       <option value='0'>--</option>";
                // fills the list-box
                foreach ($select as $key => $val) {
                    echo "<option value=\"{$key}\">{$val['Lettre']}</option>";
                }
                echo "</select></div></td>\n                                    <td width='200'>";
                if (isset($select[$cpt2])) {
                    echo '<b>' . $select[$cpt2]['Lettre'] . '.</b> ' . $select[$cpt2]['Reponse'];
                } else {
                    echo '&nbsp;';
                }
                echo "</td></tr></table></td></tr>";
                $cpt2++;
                // if the left side of the "matching" has been completely shown
                if ($answerId == $nbrAnswers) {
                    // if it remains answers to shown at the right side
                    while (isset($select[$cpt2])) {
                        echo "<tr class='even'>\n                                                <td colspan='2'>\n                                                  <table>\n                                                  <tr>\n                                                    <td width='60%' colspan='2'>&nbsp;</td>\n                                                    <td width='40%' align='right' valign='top'>" . "<b>" . $select[$cpt2]['Lettre'] . ".</b> " . $select[$cpt2]['Reponse'] . "</td>\n                                                  </tr>\n                                                  </table>\n                                                </td>\n                                              </tr>";
                        $cpt2++;
                    }
                    // end while()
                }
                // end if()
            }
        } elseif ($answerType == TRUE_FALSE) {
            echo "<tr class='even'>\n                                <td width='1' align='center'>\n                                <input type='radio' name='choice[{$questionId}]' value='{$answerId}' />\n                                </td><td>{$answer}</td>\n                                </tr>";
        }
    }
    // end for()
    if (!$nbrAnswers) {
        echo "<tr><td colspan='2'><div class='alert alert-danger'>{$langNoAnswer}</div></td></tr>";
    }
    // destruction of the Answer object
    unset($objAnswerTmp);
    // destruction of the Question object
    unset($objQuestionTmp);
    return $nbrAnswers;
}
Example #10
0
 if (!isset($user_stats[$myrow->poster_id])) {
     $user_num_posts = Database::get()->querySingle("SELECT num_posts FROM forum_user_stats WHERE user_id = ?d AND course_id = ?d", $myrow->poster_id, $course_id);
     if ($user_num_posts) {
         if ($user_num_posts->num_posts == 1) {
             $user_stats[$myrow->poster_id] = "<br/>" . $user_num_posts->num_posts . " {$langMessage}";
         } else {
             $user_stats[$myrow->poster_id] = "<br/>" . $user_num_posts->num_posts . " {$langMessages}";
         }
     } else {
         $user_stats[$myrow->poster_id] = '';
     }
 }
 $tool_content .= "<td valign='top'>" . display_user($myrow->poster_id) . $user_stats[$myrow->poster_id] . "</td>";
 $message = $myrow->post_text;
 // support for math symbols
 $message = mathfilter($message, 12, "../../courses/mathimg/");
 if ($count == 0) {
     $postTitle = "<b>{$langPostTitle}: </b>" . q($topic_subject);
 } else {
     $postTitle = "";
 }
 $rate_str = "";
 if (setting_get(SETTING_FORUM_RATING_ENABLE, $course_id)) {
     $rating = new Rating('thumbs_up', 'forum_post', $myrow->id);
     $rate_str = $rating->put($is_editor, $uid, $course_id);
 }
 $anchor_link = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;topic={$topic}&amp;forum={$forum}&amp;post_id={$myrow->id}#{$myrow->id}'>#{$myrow->id}</a><br/>";
 if ($myrow->parent_post_id == -1) {
     $parent_post_link = "<br/>{$langForumPostParentDel}";
 } elseif ($myrow->parent_post_id != 0) {
     $parent_post_link = "{$langForumPostParent}<a href='viewtopic.php?course={$course_code}&amp;topic={$topic}&amp;forum={$forum}&amp;post_id={$myrow->parent_post_id}#{$myrow->parent_post_id}'>#{$myrow->parent_post_id}</a><br/><br/>";
Example #11
0
         $tool_content .= "\n                            <tr class='even'>\n                              <td><b>{$langElementList}</b></td>\n                              <td><b>{$langCorrespondsTo}</b></td>\n                            </tr>";
     }
 }
 if ($answerType != FREE_TEXT) {
     // if NOT FREE TEXT (i.e. question has answers)
     // construction of the Answer object
     $objAnswerTmp = new Answer($row->question_id);
     $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
     for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
         $answer = $objAnswerTmp->selectAnswer($answerId);
         $answerComment = $objAnswerTmp->selectComment($answerId);
         $answerCorrect = $objAnswerTmp->isCorrect($answerId);
         $answerWeighting = $objAnswerTmp->selectWeighting($answerId);
         // support for math symbols
         $answer = mathfilter($answer, 12, "../../courses/mathimg/");
         $answerComment = mathfilter($answerComment, 12, "../../courses/mathimg/");
         switch ($answerType) {
             // for unique answer
             case UNIQUE_ANSWER:
                 $studentChoice = $choice == $answerId ? 1 : 0;
                 if ($studentChoice) {
                     $questionScore += $answerWeighting;
                 }
                 break;
                 // for multiple answers
             // for multiple answers
             case MULTIPLE_ANSWER:
                 $studentChoice = @$choice[$answerId];
                 if ($studentChoice) {
                     $questionScore += $answerWeighting;
                 }
Example #12
0
     }
     
     $options = action_button(array(
                    array('title' => $langAbuseReportClose,
                          'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=close&amp;report=$report->id",
                          'icon' => 'fa-archive',
                          'confirm' => $langConfirmAbuseReportClose,
                          'confirm_title' => $langAbuseReportClose,
                          'confirm_button' => $langClose),
                    array('title' => $langVisitReportedResource,
                          'url' => $visiturl,
                          'icon' => 'fa-external-link'),
                ));
 } elseif ($report->rtype == 'forum_post') {
     $res = Database::get()->querySingle("SELECT post_text FROM forum_post WHERE id = ?d", $report->rid);
     $content = mathfilter($res->post_text, 12, "../../courses/mathimg/");
     
     $res = Database::get()->querySingle("SELECT t.id, t.forum_id FROM forum_post as p, forum_topic as t
                 WHERE p.topic_id = t.id AND p.id = ?d", $report->rid);
     $visiturl = $urlServer."modules/forum/viewtopic.php?course=".$course_code."&topic=".$res->id."&forum=".$res->forum_id."&post_id=".$report->rid."#".$report->rid;
     $editurl = $urlServer."modules/forum/editpost.php?course=".$course_code."&topic=".$res->id."&forum=".$res->forum_id."&post_id=".$report->rid;
     $deleteurl = $urlServer."modules/forum/viewtopic.php?course=".$course_code."&topic=".$res->id."&forum=".$res->forum_id."&post_id=".$report->rid."&delete=on";
     
     $options = action_button(array(
                    array('title' => $langAbuseReportClose,
                          'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=close&amp;report=$report->id",
                          'icon' => 'fa-archive',
                          'confirm' => $langConfirmAbuseReportClose,
                          'confirm_title' => $langAbuseReportClose,
                          'confirm_button' => $langClose),
                    array('title' => $langVisitReportedResource,
 public function _from_xtcode_to_xml($texte)
 {
     $texte = htmlspecialchars($texte);
     $texte = str_replace('&quot;', '"', $texte);
     $texte = preg_replace('`\\|code(="(.+)")\\|(.*)\\|/code\\|`isU', '<code nom="$2"><![CDATA[$3]]></code>', $texte);
     $texte = preg_replace('`\\|minicode(="(.+)")\\|(.*)\\|/minicode\\|`isU', '<minicode nom="$2"><![CDATA[$3]]></minicode>', $texte);
     $texte = nl2br($texte);
     $texte = str_replace('<br />', '<saut />', $texte);
     foreach ($this->_tags as $key => $keyConfig) {
         if (substr_count($texte, $key) > 0) {
             $nbParams = array_key_exists('nbParams', $keyConfig) ? $keyConfig['nbParams'] : 0;
             $keyConfig['type'] = array_key_exists('type', $keyConfig) ? $keyConfig['type'] : 'normale';
             $keyConfig['name_xml'] = array_key_exists('name_xml', $keyConfig) ? $keyConfig['name_xml'] : $key;
             if ($keyConfig['type'] == 'normale' || $keyConfig['type'] == 'image') {
                 $toAddXtc = null;
                 $toAddXml = null;
                 $addI = 0;
                 $indicMiddle = 1;
                 if ($keyConfig['type'] == 'image') {
                     $texte = preg_replace('`\\|image\\|(.+)\\|/image\\|`isU', '<image lien="$1">Image Utilisateur</image>', $texte);
                 }
                 for ($i = 1; $i <= $nbParams; $i++) {
                     $verifP = array_key_exists('choicesParam_' . $i, $keyConfig) && $keyConfig['choicesParam_' . $i] == true ? '(' . $keyConfig['choicesParam_' . $i] . ')' : '(.+)';
                     if ($i == 1) {
                         if (array_key_exists('optionalParam_' . $i, $keyConfig)) {
                             if ($keyConfig['optionalParam_' . $i] === true) {
                                 $texte = preg_replace('`\\|' . $key . '\\|(.+)\\|/' . $key . '\\|`isU', '<' . $keyConfig['name_xml'] . '>$' . $indicMiddle . '</' . $keyConfig['name_xml'] . '>', $texte);
                             } elseif ($keyConfig['optionalParam_' . $i] == true && array_search($keyConfig['optionalParam_' . $i], $keyConfig) == true) {
                                 $texte = preg_replace('`\\|' . $key . '\\|(.+)\\|/' . $key . '\\|`isU', '<' . $keyConfig['name_xml'] . ' ' . $keyConfig['optionalParam_' . $i] . '="$1">$1</' . $keyConfig['name_xml'] . '>', $texte);
                             }
                         } elseif (array_key_exists('defaultXml_' . $i, $keyConfig)) {
                             $texte = preg_replace('`\\|' . $key . '\\|(.+)\\|/' . $key . '\\|`isU', '<' . $keyConfig['name_xml'] . ' ' . $keyConfig['paramXml_' . $i] . '="' . $keyConfig['defaultXml_' . $i] . '">$' . $indicMiddle . '</' . $keyConfig['name_xml'] . '>', $texte);
                         }
                         $toAddXtc .= '="' . $verifP . '"';
                         $indicMiddle = 2;
                     } else {
                         if (array_key_exists('optionalParam_' . $i, $keyConfig) && $keyConfig['optionalParam_' . $i] === true) {
                             $texte = preg_replace('`\\|' . $key . $toAddXtc . '\\|(.+)\\|/' . $key . '\\|`isU', '<' . $keyConfig['name_xml'] . $toAddXml . '>$' . $indicMiddle . '</' . $keyConfig['name_xml'] . '>', $texte);
                         }
                         $toAddXtc .= ' ' . (isset($keyConfig['paramXtc_' . $i]) ? $keyConfig['paramXtc_' . $i] : $keyConfig['paramXml_' . $i]) . '="' . $verifP . '"';
                         $indicMiddle = $nbParams + 1;
                     }
                     $toAddXml .= ' ' . $keyConfig['paramXml_' . $i] . '="$' . $i . '"';
                 }
                 $texte = preg_replace('`\\|' . $key . $toAddXtc . '\\|(.+)\\|/' . $key . '\\|`isU', '<' . $keyConfig['name_xml'] . $toAddXml . '>$' . $indicMiddle . '</' . $keyConfig['name_xml'] . '>', $texte);
             }
         }
     }
     load('phpmathpublisher/mathpublisher', INC_LOAD);
     $results = array();
     while (preg_match('`\\|math\\|(.*)\\|/math\\|`isU', $texte, $results)) {
         $str = $results[1];
         if (strlen($str) > 1000) {
             $texte = str_replace('|math|' . $str . '|/math|', '', $texte);
             continue;
         }
         $img = mathfilter('<m>' . $str . '</m>', 15, ROOTU . 'cache/maths/');
         $matches = array();
         preg_match('`"(http://.+)"`isU', $img, $matches);
         echoa($matches);
         $adresse = trim($matches[0], '"');
         $texte = str_replace('|math|' . $str . '|/math|', '<math lien="' . $adresse . '" form="' . $str . '" />', $texte);
         break;
     }
     #$texte = preg_replace('`<code(\snom="(.+)")>(.*)<br />(.*)</code>`isU', '<code nom="$2">$3$4</code>', $texte );
     #$texte = preg_replace('`<minicode(\snom="(.+)")>((.*)<saut />(.*))*</minicode>`isU', '<minicode nom="$2">$4$5</minicode>', $texte );
     #		$texte = preg_replace('`<liste>(<saut />\s)*<puce>`sU', '<liste><puce>', $texte);
     #		$texte = preg_replace('`</puce>(<saut />\s)*<puce>`sU', '</puce><puce>', $texte);
     #		$texte = preg_replace('`</puce>(<br />\s)*<liste>`sU', '</puce><liste>', $texte);
     #		$texte = preg_replace('`</liste>(<br />\s)*</puce>`sU', '</liste></puce>', $texte);
     #		$texte = preg_replace('`</puce>(<br />\s)*</liste>`sU', '</puce></liste>', $texte);
     $this->xml_content = $texte;
     return $texte;
 }
Example #14
0
<?php

include 'mathpublisher.php';
include "mathpublisher.php";
mathfilter("<m>f(x)=sqrt{x}</m>");
Example #15
0
</head>
<body style='background: white;'>
<?php
    // display message list
    $fileContent = file($fileChatName);
    $FileNbLine = count($fileContent);
    $lineToRemove = $FileNbLine - MESSAGE_LINE_NB;
    if ($lineToRemove < 0) {
        $lineToRemove = 0;
    }
    $tmp = array_splice($fileContent, 0, $lineToRemove);
    
    $fileReverse = array_reverse($fileContent);    
    foreach ($fileReverse as $thisLine) {
        $thisLine = preg_replace_callback('/\[m\].*?\[\/m\]/s', 'math_unescape', $thisLine);
        $newline = mathfilter($thisLine, 12, '../../courses/mathimg/');
        $str_1 = explode(' !@#$ ', $newline);
        
        //New message system (Opecart 3.0 generated conferences)
        if (isset($str_1[1])) {
            if (trim($str_1[1]) == "systemMsgClear" || trim($str_1[1]) == "systemMsgSave") {
                if (trim($str_1[1]) == "systemMsgClear"){
                    $class = 'alert-success';
                } else {
                    $class = 'alert-info';
                }
                echo "<div class='row margin-right-thin margin-left-thin margin-top-thin'>
                            <div class='col-xs-12'>
                                <div class='alert $class text-center'>
                                    $str_1[0]
                                </div>
Example #16
0
function standard_text_escape($text, $mathimg = '../../courses/mathimg/')
{
    global $purifier;
    $text = preg_replace_callback('/\\[m\\].*?\\[\\/m\\]/s', 'math_unescape', $text);
    $html = $purifier->purify(mathfilter($text, 12, $mathimg));
    if (!isset($_SESSION['glossary_terms_regexp'])) {
        return $html;
    }
    $dom = new DOMDocument();
    // workaround because DOM doesn't handle utf8 encoding correctly.
    @$dom->loadHTML('<div>' . mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8') . '</div>');
    $xpath = new DOMXpath($dom);
    $textNodes = $xpath->query('//text()');
    foreach ($textNodes as $textNode) {
        if (!empty($textNode->data)) {
            $new_contents = glossary_expand($textNode->data);
            if ($new_contents != $textNode->data) {
                $newdoc = new DOMDocument();
                $newdoc->loadXML('<span>' . $new_contents . '</span>', LIBXML_NONET | LIBXML_DTDLOAD | LIBXML_DTDATTR);
                $newnode = $dom->importNode($newdoc->getElementsByTagName('span')->item(0), true);
                $textNode->parentNode->replaceChild($newnode, $textNode);
                unset($newdoc);
                unset($newnode);
            }
        }
    }
    $base_node = $dom->getElementsByTagName('div')->item(0);
    // iframe hack
    return preg_replace(array('|^<div>(.*)</div>$|s', '#(<iframe [^>]+)/>#'), array('\\1', '\\1></iframe>'), dom_save_html($dom, $base_node));
}
Example #17
0
                        <td><b>$langCorrespondsTo</b></td>
                        </tr>";
        }
    }
    // construction of the Answer object
    $objAnswerTmp = new Answer($questionId);
    $nbrAnswers = $objAnswerTmp->selectNbrAnswers();

    for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
        $answer = $objAnswerTmp->selectAnswer($answerId);
        $answerComment = $objAnswerTmp->selectComment($answerId);
        $answerCorrect = $objAnswerTmp->isCorrect($answerId);
        $answerWeighting = $objAnswerTmp->selectWeighting($answerId);
        // support for math symbols
        $answer = mathfilter($answer, 12, "$webDir/courses/mathimg/");
        $answerComment = mathfilter($answerComment, 12, "$webDir/courses/mathimg/");

        switch ($answerType) {
            // for unique answer
            case UNIQUE_ANSWER : $studentChoice = ($choice == $answerId) ? 1 : 0;
                if ($studentChoice) {
                    $questionScore+=$answerWeighting;
                    $totalScore+=$answerWeighting;
                }
                break;
            // for multiple answers
            case MULTIPLE_ANSWER : $studentChoice = @$choice[$answerId];
                if ($studentChoice) {
                    $questionScore+=$answerWeighting;
                    $totalScore+=$answerWeighting;
                }
 function _math_code($matches)
 {
     $matches[1] = str_replace('<br />', '', $matches[1]);
     $matches = mathfilter(html_entity_decode($matches[1], ENT_COMPAT, 'ISO-8859-1'), 12);
     return $matches;
 }