Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering source-code with highligted syntax in the quiz forms #239

Open
dipanjanchakraborty opened this issue Mar 3, 2024 · 9 comments

Comments

@dipanjanchakraborty
Copy link

dipanjanchakraborty commented Mar 3, 2024

I am creating an offline quiz for a programming course. The questions and the answer options might have code snippets (in Java). I can use the option in the moodle question creation interface to highlight the syntax of the source code, and this renders fine on the moodle interface.

However, when generating the PDF forms for the quiz, all the lines in the code are rendered in one single continuous lines (the newlines in the "pre" environment are ignored).

Is there any work around for this?

@obook
Copy link

obook commented Mar 6, 2024

Hello.
This bug is for all code snippets, without highlight filter also. I thing the problem is "pre" tag is removed, "code" tag is preserved.

Actual bug :
Capture d’écran 2024-03-06 144434

Expected :
Capture d’écran 2024-03-06 144402

Actually, I try to find in source code where "pre" is removed.
This bug is seriously problematic for computer science assessments.

Olivier

@obook
Copy link

obook commented Mar 6, 2024

Is maybe a problem with ATTO html editor.
I actually make tests with TinyMCE HTML editor.

Regards.

@obook
Copy link

obook commented Mar 6, 2024

@dipanjanchakraborty : no problem with TinyMCE HTML editor...

@dipanjanchakraborty
Copy link
Author

@obook same outcome even with TinyMCE HTML editor

Preview is fine:
Screenshot from 2024-03-07 10-40-10

But the PDF form is not:
Screenshot from 2024-03-07 10-40-44

This is the xml for the question:

<!-- question: 8  -->
  <question type="multichoice">
    <name>
      <text>Question 7</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Consider the code below:</p>
<pre class="language-java"><code>class Voop {
     public static void main(String[] args) {
          doStuff(1);
          doStuff(1, 2);
     }
     // insert code here
}</code></pre>
<p>Which of the following line(s) if inserted in line 6 above will compile?</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.3333333</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <single>false</single>
    <shuffleanswers>true</shuffleanswers>
    <answernumbering>abc</answernumbering>
    <showstandardinstruction>0</showstandardinstruction>
    <correctfeedback format="html">
      <text><![CDATA[<p>Your answer is correct.</p>]]></text>
    </correctfeedback>
    <partiallycorrectfeedback format="html">
      <text><![CDATA[<p>Your answer is partially correct.</p>]]></text>
    </partiallycorrectfeedback>
    <incorrectfeedback format="html">
      <text><![CDATA[<p>Your answer is incorrect.</p>]]></text>
    </incorrectfeedback>
    <shownumcorrect/>
    <answer fraction="50" format="html">
      <text><![CDATA[<p>static void doStuff(int... doArgs) { }</p>]]></text>
      <feedback format="html">
        <text></text>
      </feedback>
    </answer>
    <answer fraction="-50" format="html">
      <text><![CDATA[<p>static void doStuff(int[] doArgs) { }</p>]]></text>
      <feedback format="html">
        <text></text>
      </feedback>
    </answer>
    <answer fraction="50" format="html">
      <text><![CDATA[<p>static void doStuff(int x, int... doArgs) { }</p>]]></text>
      <feedback format="html">
        <text></text>
      </feedback>
    </answer>
    <answer fraction="-50" format="html">
      <text><![CDATA[<p>static void doStuff(int... doArgs, int y) { }</p>]]></text>
      <feedback format="html">
        <text></text>
      </feedback>
    </answer>
  </question>

@obook
Copy link

obook commented Mar 7, 2024

I make my question via https://smb33.keosystems.com/qcm/
Is GIFT format only (not XML), imported in question library, and run great in PDF.

@cmichale
Copy link

cmichale commented Mar 7, 2024 via email

@LisaE14
Copy link

LisaE14 commented Mar 7, 2024 via email

@obook
Copy link

obook commented Mar 8, 2024

I am creating an offline quiz for a programming course. The questions and the answer options might have code snippets (in Java). I can use the option in the moodle question creation interface to highlight the syntax of the source code, and this renders fine on the moodle interface.

However, when generating the PDF forms for the quiz, all the lines in the code are rendered in one single continuous lines (the newlines in the "pre" environment are ignored).

Is there any work around for this?

Finally, I think is Moodle HTML editors fault, not moodle-mod_offlinequiz.
So I use the tool online https://smb33.keosystems.com/qcm/ for make my questions.

This is a screenshot of PDF made with this tool:

Copie d'écran_20240308_220213

@dipanjanchakraborty
Copy link
Author

dipanjanchakraborty commented Mar 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants