ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Strip slashes causing a problem with LaTeX


  • 2009-07-11 00:07:19

    Strip slashes causing a problem with LaTeX

    Hello. I have 1.6.2 installed and I'm using LaTeX to write math equations.

    I think the "stripslashes" code is interfering though. For example, in LaTeX, the "square root of 50" is written as "\sqrt{50}". When I initially enter than into a question in Tests and Surveys, it displays fine. However, the second time (and every time thereafter) I preview that question, it doesn't display right.

    The reason I think stripslashes is involved is because when I go back to the question to edit it none of the "\" marks are there causing the LaTeX elements that rely on those to not display properly.

    Any thoughts?

    Thanks.

  • 2009-07-11 09:03:01

    Re: Strip slashes causing a problem with LaTeX?

    Did you use the [tex]\sqrt{50}[/tex] tags?

  • 2009-07-12 15:34:31

    Re: Strip slashes causing a problem with LaTeX?

    No. I use the <code lang="latex"></code> and <pre lang="latex"></pre> tags because I put:

    [php]<script type="text/javascript" src="http://latex.codecogs.com/render.js"></script>
    [/php]

    on my ATutor pages to display LaTeX in Tests and Surveys.


    1.6.2 doesn't support LaTeX for Tests and Surveys does it?

  • 2009-07-12 15:35:40

    Re: Strip slashes causing a problem with LaTeX?

    Note: Disregard the beginning and ending php tags in my last post.

  • 2009-07-13 08:47:04

    Re: Strip slashes causing a problem with LaTeX?

    I don't know how render.js works, so you're on your own.

    1.6.3 will be out in a couple weeks. It will support LaTeX all around.

  • 2010-01-14 17:35:27

    Re: Strip slashes causing a problem with LaTeX?

    I am having the same stripslashes problem.

    I am using 1.6.3 which has latex embedding included with the [tex] [/tex] tags.

    Latex works perfectly everywhere except in the tests section.

    In the tests section I have the same problem you are having where my back slashes get somehow automatically taken away.

    Did you find a fix for this?
    What is the strip slashes code? Does it serve some useful purpose or can I just remove it? or edit it so it leaves my latex alone?

    I am confused because this only happens with the editor in the test section not with the editor anywhere else so I am wondering if there is just a line of code missing somewhere in the editor call; can anyone help me in which files I should look at or compare to see why (and hopefully fix) I am getting this problem only in the tests section.
    (Have just installed all the patches for 1.6.3, though two of the patches (4 and 7) had to be undone as they stopped Atutor from working. But the patches didn't fix the latex problem.)

    Thanks alot,
    Lara

  • 2010-01-16 11:45:22

    Re: Strip slashes causing a problem with LaTeX?

    Lara,

    I did come up with a solution and I haven't seen any adverse effects from it. Maybe there's a better way though.

    Example of what I did....

    In /ATutor/tools/tests/edit_question_matching.php around line 187 (it will probably be different for you because my installation has been modified)...

    REPLACE:

    "echo htmlspecialchars(stripslashes($_POST['question']));"

    WITH:

    "echo htmlspecialchars($_POST['question']);"



    Then around line 203...

    REPLACE:

    "echo htmlspecialchars(stripslashes($_POST['answer']));"

    WITH:

    "echo htmlspecialchars($_POST['answer']);"



    You'll need to do a similar thing for all of the question types.

    Hope it helps!

  • 2010-01-18 21:40:38

    Re: Strip slashes causing a problem with LaTeX?

    Thanks a lot :).

    That solved half my problem (the half that was the same as yours). I now no longer have back slashes getting removed and the latex appears correctly in my questions all the time.

    I still have a problem with the optional feedback section of long answer questions which doesn't recognise the [tex] [/tex] tags.

    Does anyone have any idea which file is doing the formatting and output of text entered in the optional feedback section? i.e. is there another file (other than include/lib/output.inc.php) in which I need to add the code about interpreting [tex][/tex] tags?

    Thanks a lot,
    Lara

  • 2010-01-19 06:20:52

    Re: Strip slashes causing a problem with LaTeX?

    Fix to above (my second problem see post above--re latex not being formatted in the optional feedback section of long questions) in Atutor 1.6.3 (after much frustration--given I know neither php nor html syntax!)

    Line 152 of ATutor-1.6.3/ATutor/tools/view_results.php
    changed from commented out line below to the line now above

    if ($row['feedback']) {
    /*line 151*/
    echo '<div class="row"><p><strong>'._AT('feedback').':</strong></p><p> ';
    /*new line 152*/
    echo AT_print($row['feedback'],'tests_questions.feedback').'</p></div>';
    /*removed line 152*/
    /*echo nl2br($row['feedback']).'</p></div>';*/
    }

    This seems to work, but I've only checked against my own test results not other users.

    There is another file with the same name within the tests directory which I've also changed in the same manner (well that was the one I changed first---and it didn't seem to work, cue increasing frustration!!); really not sure when this second file gets called or by what function but I've left it changed for now.

  • 2010-01-19 16:30:58

    Re: Strip slashes causing a problem with LaTeX?

    Patch #04 for 1.6.4 has been issued for this fix. Please login as admin, go to "Patcher" to install, provided u r using ATutor 1.6.4

    Cheers!