ATutor

Learning Management Tools







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


Mystery ltps in Test Questions


  • 2015-06-08 20:17:51

    Mystery ltps in Test Questions

    I have a modified version of 2.0 installed and I noticed an odd thing today in the way test questions are being displayed.

    My question text is [b]What would the whole number part of <div class="fraction_display"><span class="numer_display">9</span><span class="bar_display">/</span><span class="denom_display">4</div> be if you converted it into a mixed number?[/b]. The <div class="fraction_display"> part is a way to display fractions as nice looking fractions that's unique to my site.

    The problem is that the question text above outputs to [b]<p>What would the whole number part of </p><div class="fraction_display"><span class="numer_display">9</span><span class="bar_display">/</span><span class="denom_display">4</span></div> be if you converted it into a mixed number?[/b].

    Notice the mystery <p> that shows up. Where does that come from and how can I turn it off? It creates an issue with the proper displaying of fractions on my end (see attached screenshot).

    Thanks!

  • 2015-06-11 07:12:56

    Re: Mystery <p>'s in Test Questions?

    A div inside a paragraph would be invalid HTML. The editor is likely trying to fix it.

  • 2015-06-11 10:08:06

    Re: Mystery <p>'s in Test Questions?

    In the DB, the text of the "question" field is [b]What would the whole number part of <div class="fraction_display"><span class="numer_display">9</span><span class="bar_display">/</span><span class="denom_display">4</div> be if you converted it into a mixed number?[/b]

    There are no <p> tags present. So, it seems that the script that displays the questions is automatically putting the question text in a <p>. Do you know where I could go to turn that off?

    Thanks.

  • 2015-06-11 10:16:06

    Re: Mystery <p>'s in Test Questions?

    Actually, I think I just found it. The <p> tags seem to be added from each question type's /path/to/your/ATutor/installation/themes/default/test_questions/[question_type].tmpl.php file.

    Greg: Can you see any reason why taking out the <p> tags from those files would cause something to break or not display correctly?

    Thanks!

  • 2015-06-11 10:17:54

    Re: Mystery <p>'s in Test Questions?

    The text does need to be in some sort of container. TinyMCE automatically uses P tags if nothing else is specified.

    Turning that off would be question for the TinyMCE people. My guess is it would be a change in the code.

  • 2015-06-11 10:27:12

    Re: Mystery <p>'s in Test Questions?

    As an experiment, in the "multichoice.tmpl.php" file, I changed this...

    [quote]<p><?php echo AT_print($this->row['question'], 'tests_questions.question'); ?></p>[/quote]

    to this...

    [quote]<?php echo AT_print($this->row['question'], 'tests_questions.question'); ?>[/quote]


    Then when I previewed the question it rendered this HTML...

    [quote]

    <div style="padding-bottom: 20px" class="row">What would the whole number part of <div class="fraction_display"><span class="numer_display">9</span><span class="bar_display">/</span><span class="denom_display">4</span></div> be if you converted it into a mixed number?

    ...[MULTIPLE CHOICE ANSWERS AS A <ul>]...

    </div>
    [/quote]


    So, it appears that you're going to get the question placed in a <div> automatically, this meeting the "container requirement" you mentioned above.

    Thoughts about this?


    BTW, this isn't a TinyMCE thing. I was using the plain text editor when I created this question.

  • 2015-06-11 11:00:44

    Re: Mystery <p>'s in Test Questions?

    I see. The P tags are added by the question templates in the themes/default/test_questions/ directory.

    I would strongly recommend against changing the default templates. If you must, copy them into a custom theme, reproducing the same directory structure, and edit them there.

    Myself, I'd probably look for a different strategy, maybe try replacing the fraction_display divs with spans.

  • 2015-06-11 11:23:40

    Re: Mystery <p>'s in Test Questions?

    Is there a programmatic reason for not changing the templates, or just a preference for the <p> tags? It seems that displaying content in a <p> tag or not has negligible consequences, but let me know if I'm missing something.

    Thanks.

  • 2015-06-11 11:37:18

    Re: Mystery <p>'s in Test Questions?

    No programmatic reason, though you'd need to keep track of the changes to the default theme, so they can be reapplied during an upgrade.

    If you recreate the templates as part of a theme, when you re-enable the theme after an upgrade, your modifications will be maintained.

  • 2015-06-11 11:37:50

    Re: Mystery <p>'s in Test Questions?

    Great. Thanks!